#include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 200000 + 20;
const int maxm = 50 + 5;
int n;
int p;
int k;
int co[maxn];
int val[maxn];
int sum[2][maxm];
int ans = 0;
int main()
{
freopen("hotel.in","r",stdin);
freopen("hotel.out","w",stdout);
scanf("%d%d%d",&n,&k,&p);
for(int i = 1;i <= n; i ++)
{
scanf("%d%d",&co[i],&val[i]);
sum[1][co[i]]++;
if(val[i]<=p)
{
for(int j = 0;j <= k - 1; j ++)
{
sum[0][j] += sum[1][j];
sum[1][j] = 0;
}
ans -= 1;
}
ans += sum[0][co[i]];
}
cout<<ans;
return 0;
}