#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const long long mod = 1e9 + 7;
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long fast_pow(long long base, long long n, long long M = inf) {
  if (n == 0) return 1;
  if (n == 1) return base;
  long long halfn = fast_pow(base, n / 2, M);
  if (n % 2 == 0)
    return (halfn * halfn) % M;
  else
    return (((halfn * halfn) % M) * base) % M;
}
long long comp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first == b.first) return a.second > b.second;
  return a.first < b.first;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, i, j, x, y, r, c(0);
  cin >> n;
  pair<long long, long long> a[n];
  for (i = 0; i < n; ++i) {
    cin >> x >> y;
    a[i] = {x, y};
  }
  sort(a, a + n, comp);
  r = a[0].second;
  for (i = 1; i < n; ++i) {
    if (a[i].second < r)
      ++c;
    else
      r = a[i].second;
  }
  cout << c;
}
