#include<bits/stdc++.h>
using namespace std;
const int N=3e4+5;
int n;
int tot=0;
struct humen{
int h;
int w;
}a[N];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].h>>a[i].w;
}
for(int i=1;i<=n;i++){
for(int j=1+i;j<=n;j++){
if(a[i].h<a[j].h){
swap(a[i],a[j]);
tot++;
}
else if(a[i].h==a[j].h){
if(a[i].w<a[j].w){
swap(a[i],a[j]);
tot++;
}
}
}
}
cout<<tot;
return 0;
}
qwq求求