#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
int ll_max = 1e6;
vector<long long int> fact;
void factorial(long long int n) {
  fact[0] = 1;
  for (long long int i = 1; i <= n; i++) {
    fact[i] = i * fact[i - 1];
    fact[i] %= M;
  }
}
long long int binpow(long long int val, long long int deg) {
  if (!deg) return 1 % M;
  if (deg & 1) return binpow(val, deg - 1) * val % M;
  long long int res = binpow(val, deg >> 1);
  return (res * res) % M;
}
long long int combination(long long int n, long long int i) {
  long long int res = fact[n];
  long long int div = fact[n - i] * fact[i];
  div %= M;
  div = binpow(div, M - 2);
  return (res * div) % M;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n, m, i;
  long long int j, t, x, y, z, k, d;
  cin >> n;
  long long int b[n], a[n];
  vector<pair<long long int, long long int>> l1;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    l1.push_back(make_pair(a[i], b[i]));
  }
  sort(l1.begin(), l1.end());
  long long int max = 0;
  long long int sum = 0;
  for (long long int i = 0; i < n; i++) {
    x = l1[i].second;
    if (x > max)
      max = x;
    else if (x < max) {
      sum++;
    }
  }
  cout << sum;
  return 0;
}
