#include <bits/stdc++.h>
#pragma GCC optimize("O3")
int const N = 1e5 + 5, M = 105;
using namespace std;
long long n, high, ans;
pair<long long, long long> arr[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i].first >> arr[i].second;
  sort(arr, arr + n);
  for (int i = 0; i < n; i++) {
    if (arr[i].second < high) ans++;
    high = max(high, arr[i].second);
  }
  cout << ans;
  return 0;
}
