#include <bits/stdc++.h>
using namespace std;
struct node {
  int st, en;
} num[100005], save[100005];
bool cmp(node a, node b) { return a.st < b.st; }
int main() {
  int icase, i, j, sum;
  while (cin >> icase) {
    sum = 0;
    for (i = 0; i < icase; ++i) {
      scanf("%d%d", &num[i].st, &num[i].en);
    }
    sort(num, num + icase, cmp);
    int start, end;
    for (i = 0; i < icase; ++i) {
      start = num[i].st;
      end = num[i].en;
      for (j = i + 1; j < icase; ++j) {
        if (start < num[j].st && end > num[j].en) {
          ++sum;
        } else {
          i = j - 1;
          break;
        }
      }
      if (j == icase) {
        break;
      }
    }
    cout << sum << endl;
  }
  return 0;
}
