include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[10000000];
vector<int> V[100005];
map<ll, ll> tp;
int x[1000000];
int y[1000000];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
int ma1 = 0x3f3f3f3f;
int ma2 = 0x3f3f3f3f;
for(int i = 1; i <= n; i++)
{
cin >> x[i] >> y[i];</int>
} int cnt = 0; for(int i = 1; i <= n; i++) { for(int j = 1; j <= n; j++) { if(i == j) continue; if(x[i] <= x[j] && y[i] <= y[j]) { cnt++; break; } } } cout << cnt << "\n"; return 0;
}