#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int N = 110;
int st[N],cnt[N];
int main()
{
int n,res = 0;
cin>>n;
memset(st,-1,sizeof st);
for(int i = 0;i < n;i++){
int x,state;
cin>>x>>state;
if(st[x] != -1 && st[x] == !state){
st[x] = state;
res++;
}else st[x] = state;
}
cout<<res;
return 0;
}