#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 1e5 + 10;
pair<int,int> a[N];
int n;
int main(){
    scanf("%d",&n);
    for(int i = 1;i <= n;i++){
        scanf("%d%d",&a[i].first,&a[i].second);
    } 
    sort(a+1,a+1+n);
    int mx = 0;
    int ans = 0;
    for(int i = n;i > 0;i--){
        if(a[i].second < mx) ans++;
        mx = max(a[i].second,mx);
    }
    printf("%d\n",ans);
    return 0;
}