#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c = 0;
  pair<int, int> p[100000];
  scanf("%d", &n);
  for (int x, y, i = 0; i < n; i++) {
    cin >> x >> y;
    p[i] = make_pair(x, y);
  }
  sort(p, p + n);
  priority_queue<int> q;
  q.push(p[0].second);
  for (int i = 1; i < n; i++) {
    q.push(p[i].second);
    if (p[i].second != q.top()) c++;
  }
  cout << c << endl;
  return 0;
}
