// prob A contest 217 codeforces
#include <bits/stdc++.h>
using namespace std;
bool x[1005];
bool y[1005];
int main()
{
int n;
cin>>n;
int ans=-1;
memset(x,false,sizeof(x));
memset(y,false,sizeof(y));
for(int i=0;i<n;i++)
{
int xi,yi;
cin>>xi>>yi;
if(x[xi]==false && y[yi]==false) ans+=1;
x[xi]=true;
y[yi]=true;
}
cout<<ans<<endl;
return 0;
}
Ly8gcHJvYiBBIGNvbnRlc3QgMjE3IGNvZGVmb3JjZXMKI2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpib29sIHhbMTAwNV07CmJvb2wgeVsxMDA1XTsKCmludCBtYWluKCkKewoJaW50IG47CgljaW4+Pm47CglpbnQgYW5zPS0xOwoJbWVtc2V0KHgsZmFsc2Usc2l6ZW9mKHgpKTsKCW1lbXNldCh5LGZhbHNlLHNpemVvZih5KSk7Cglmb3IoaW50IGk9MDtpPG47aSsrKQoJewoJCWludCB4aSx5aTsKCQljaW4+PnhpPj55aTsKCQlpZih4W3hpXT09ZmFsc2UgJiYgeVt5aV09PWZhbHNlKSBhbnMrPTE7CgkJeFt4aV09dHJ1ZTsKCQl5W3lpXT10cnVlOwoJfQoJY291dDw8YW5zPDxlbmRsOwoJcmV0dXJuIDA7Cn0=