#include<algorithm>
#include<cmath>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<set>
using namespace std;
const int maxn=1e5+7;
int main()
{
    int n,a[maxn],b[maxn];
    while(cin>>n){
        int sum=0;
        set<int>s1,s2;
        int a,b;
        for(int i=1;i<=n/2;i++){
            cin>>a>>b;
                s1.insert(a);
                s2.insert(b);
            if(a==b)
                sum++;
        }
        cout<<(s1.size()-1+s2.size()-1+sum)<<endl;
    }
    return 0;
}