#include <bits/stdc++.h>
using namespace std;
int n;
pair<int, int> stor[100010];
bool com(pair<int, int> a, pair<int, int> b) {
  if (a.first == b.first && a.second < b.second)
    return true;
  else if (a.first < b.first)
    return true;
  return false;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    stor[i] = make_pair(u, v);
  }
  sort(stor, stor + n);
  int ans = 0, j;
  for (int i = 0; i < n - 1; i++) {
    if (stor[i].first != stor[i + 1].first) {
      for (j = i + 1; j < n; j++) {
        if (stor[j].second < stor[i].second) {
          ans++;
        } else
          break;
      }
      i = j - 1;
    }
  }
  cout << ans << endl;
}
