#include<bits/stdc++.h>
using namespace std;
int n, t;
struct student {
int h;
int w;
bool operator <(const student& a)const {
if (h == a.h) return w > a.w;
return h > a.h;
}
} s[3010];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> s[i].h >> s[i].w;
}
while (n--) {
for (int i = 1; i <= n; i++) {
if (s[i + 1] < s[i]) {
swap(s[i], s[i + 1]);
t++;
}
}
}
cout << t;
return 0;
}