#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 * 1000000 + 5;
long long c[26][maxn];
vector<long long> v[106];
long long visited[106];
void dfs(long long root) {
  if (visited[root]) return;
  visited[root] = 1;
  for (auto i : v[root]) dfs(i);
}
int main() {
  ios::sync_with_stdio(false);
  int n, d, k;
  long long t = 1;
  while (t--) {
    long long n;
    cin >> n;
    long long l[n], r[n];
    vector<pair<long long, long long> > tp;
    set<long long> rp;
    for (long long i = 0; i < n; i++) {
      cin >> l[i] >> r[i];
      tp.push_back({l[i], r[i]});
    }
    sort(begin(tp), end(tp));
    long long ans = 0;
    for (long long i = 0; i < n; i++) {
      pair<long long, long long> x = tp[i];
      if (rp.lower_bound(x.second) != rp.end()) {
        ans++;
      }
      rp.insert(x.second);
    }
    cout << ans << "\n";
  }
  return 0;
}
