#include <bits/stdc++.h>
using namespace std;

#define f first
#define s second

int main()
{
    int n;
    pair <int,int> p;
    set <int> X;
    set <int> Y;

    cin >> n;
    int br = n;
    for ( int i = 0; i < n; i++ )
    {
        cin >> p.f >> p.s;
        if ( X.find( p.f ) == X.end() )
        {
            X.insert( p.f );
            br--;
        }
        continue;
        if ( Y.find( p.s ) == Y.end() )
        {
            Y.insert( p.s );
            br--;
        }
    }
    cout << br;

    return 0;
}