#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxl=200010;
int n,k,p,i,j,c[maxl],b[maxl],num[51][maxl];
unsigned long long ans;
int main()
{
freopen("hotel.in","r",stdin);
freopen("hotel.out","w",stdout);
scanf("%d%d%d",&n,&k,&p);
for (i=1;i<=n;i++){
scanf("%d%d",&c[i],&b[i]);
num[c[i]][i]=1;
for (j=0;j<k;j++) num[j][i]+=num[j][i-1];
}
b[n+1]=-1;j=0;
for (i=1;i<=n;i++){
for (j=max(j,i);b[j]>p;j++);
if (j>n) break;
ans+=num[c[i]][n]-num[c[i]][j-1];
if (i==j) ans--;
}
cout<<ans<<endl;
return 0;
}