#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:1000000000")
set<int> st;
vector<pair<int, int> > v;
int mas[100100];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    v.push_back(make_pair(a, i));
    mas[i] = b;
  }
  sort(v.begin(), v.end());
  int cnt = 0;
  for (int i = 0, maxi = (int)v.size(); i < maxi; i++) {
    if (st.upper_bound(mas[v[i].second]) != st.end()) cnt++;
    st.insert(mas[v[i].second]);
  }
  printf("%d\n", cnt);
  return 0;
}
