#include <bits/stdc++.h>
using namespace std;
int n, k, p, t, ans = 0, price, num[110], color[200100];
int main()
{
cin >> n >> k >> p; for (int i = 1; i <= n; i++)
{
cin >> color[i] >> price;
if (price <= p)
{
for (int j = i; j > t; j--)
num[color[j]]++;
t = i;
ans += num[color[i]] - 1;
}
else ans += num[color[i]];
}
cout << ans;
return 0;
}