#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 4 * 1e5;

// union-find
struct union_find {
    vector<int> dat;

    union_find(int size) {dat.resize(size, -1);}

    int find(int x) {
        if (dat[x] < 0) {return x;}
        return dat[x] = find(dat[x]);
    }

    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) {return false;}
        if (dat[x] > dat[y]) swap(x, y);
        dat[x] += dat[y];
        dat[y] = x;
        return true;
    }

    int size(int x) {return -dat[find(x)];}

    vvint groups() {
        int n = dat.size();
        vector<vector<int>> res(n);
        for (int i = 0; i < n; i++) {
            res[find(i)].push_back(i);
        }
        res.erase(
            remove_if(res.begin(), res.end(), 
                [](const vint &v) {return v.empty();}), 
            res.end());
        return res;
    }
};

int main() {
    int n; cin >> n;
    union_find uf(MAX);
    vector<bool> B(MAX, false);
    rep(i,n) {
        int a, b; cin >> a >> b;
        a--; b--;
        if (a != b) {
            if (!uf.unite(a, b)) {
                B[a] = true; B[b] = true;
            }
        } else B[a] = true;
    }
    rep(i,MAX) {
        if (B[i]) B[uf.find(i)] = true;
    }
    vvint group = uf.groups();
    ll ans = 0;
    rep(i,group.size()) {
        if (B[uf.find(group[i][0])]) ans += group[i].size();
        else ans += group[i].size() - 1;
    }
    cout << ans << endl;
}
#include<bits/stdc++.h>
using namespace std;
vector<int> c[100005];
int n,p,s[100005];
bool cmp(pair<int,int> a,pair<int,int> b)
{
	if(a.first!=b.first) return a.first>b.first;
	return a.second>b.second;
}
void dfs1(int x)
{
	s[x]=1;
	for(int i=0;i<c[x].size();++i)
	{
		int y=c[x][i];
		dfs1(y);
		s[x]+=s[y];
	}
}
int dfs(int x)
{
	int nf=0;bool f=0;
	vector<pair<int,int> > k,k1;
	for(int i=0;i<c[x].size();++i)
	{
		int y=c[x][i],u=dfs(y);
		if(s[y]%2) k.push_back(make_pair(u*2-s[y],u));
		else k1.push_back(make_pair(u*2-s[y],u));
	}
	sort(k.begin(),k.end(),cmp);
	sort(k1.begin(),k1.end(),cmp);
	if(k.size()%2) f=1;
	for(int i=0;i<k1.size();++i)
	 if(k1[i].first>=0||!f) nf+=k1[i].second;
	 else nf+=k1[i].second-k1[i].first;
	for(int i=0;i<k.size();++i)
	 if(i%2==0) nf+=k[i].second;
	 else nf+=k[i].second-k[i].first;
	return nf;
}
int main()
{
	cin>>n;
	for(int i=1;i<n;++i)
	{
		cin>>p;
		c[p].push_back(i+1);
	}
	dfs1(1);
	cout<<n-dfs(1);
	return 0;
}