
//================code===================//

#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>

#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long
#define fa(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>b;--i)
#define setp pair<pair<int,int>,int>
#define setl pair<LL,LL>
#define M_PI 3.14159265358979323846
#define micro 0.000001

#ifdef OHSOLUTION
#define ce(t) cerr<<t
#define AT cerr << "\n=================ANS=================\n"
#define AE cerr << "\n=====================================\n"
#else
#define AT
#define AE
#define ce(t)
#endif

using namespace std;

LL gcd(LL a, LL b) { return a % b ? gcd(b, a % b) : b; }
LL lcm(LL a, LL b) { return (a * b) / gcd(a, b); }

pair <int, int> vu[8] = { {0,1},{1,0},{0,-1} ,{-1,0},{-1,1}, {0,1} , {1,1},{1,-1} }; //RDLU EWSN

template<typename T, typename U>
void ckmax(T& a, U b) { a = a < b ? b : a; }
template<typename T, typename U>
void ckmin(T& a, U b) { a = a > b ? b : a; }
struct gcmp { bool operator()(LL a, LL b) { return a < b; } };
struct lcmp { bool operator()(LL a, LL b) { return a > b; } };

const int max_v = 4e5 + 7;
const int INF = 1e9 + 7;
const LL LNF = 1e18 + 7;
const LL mod = 123456789;

int p[max_v];
int np[max_v];
int vist[max_v];	
bool check[max_v];
vector <int> vi;

int find(int idx,bool num=false)
{
	if (num) return np[idx] < 0 ? idx : np[idx] = find(np[idx],num);
	return p[idx] < 0 ? idx : p[idx] = find(p[idx],num);
}

void merge(int a, int b,bool num=false)
{
	a = find(a,num);
	b = find(b,num);

	if (a == b) return;

	if (num)
	{
		np[a] += np[b];
		np[b] = a;
		return;
	}

	merge(vi[a], vi[b],true);
	p[a] += p[b];
	p[b] = a;

}

int main()
{
#ifdef OHSOLUTION
	freopen("input.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);	
	int n; ci(n);
	memset(p, -1, sizeof(p));
	memset(np, -1, sizeof(np));

	vi.resize(n+1);

	fa(i, 1, n + 1)
	{
		int x, y; ci(x >> y);
		merge(x, y, true);
		vi[i] = x;

		if (vist[x]) merge(vist[x], i);
		else { vist[x] = i;  }
		if (vist[y]) merge(vist[y], i);
		else { vist[y] = i;}

		
	}

	LL ans = 0;
	
	fa(i, 1, n + 1)
	{
		int x = find(i);
		if (!check[x])
		{
			check[x] = true;

			ce(p[x] * -1 << " " << np[find(vi[x])] * -1 << endl);

			ans += min(p[x] * -1, np[find(vi[x],true)] *-1 );
		}
	}
	
	AT;
	co(ans);
	AE;


	return 0;
}

#include<bits/stdc++.h>
#define maxn 100005
#define LL long long
using namespace std;
struct edge{
	int nxt,to;
}e[maxn<<1];
int first[maxn],tot;
void add_edge(int x,int y){
	tot++;
	e[tot].nxt=first[x];
	e[tot].to=y;
	first[x]=tot;
}

LL sz[maxn];
LL dp[maxn];
int n;
bool pd(int x){
	LL k=3*sz[x]-2;
	if(k&1)return 1;else return 0;
}
void dfs(int x){
	sz[x]=1;
	for(int i=first[x];i!=-1;i=e[i].nxt){
		int y=e[i].to;
		dfs(y);
		sz[x]+=sz[y];
	}
}

void dfs2(int x){
	dp[x]=1;
	int cnt0=0,cnt1=0;
	multiset<LL>s0,s1;
	LL sum=0;
	s0.clear(),s1.clear();
	for(int i=first[x];i!=-1;i=e[i].nxt){
		int y=e[i].to;
		dfs2(y);
		if(sz[y]&1){
			cnt1++;
			s1.insert(dp[y]);
		}
		else{
			cnt0++;
			s0.insert(dp[y]);
		}
	}
	for(multiset<LL>::iterator it=s0.begin();it!=s0.end();it++){
		if(*it<0)
			dp[x]+=*it;
		else
			sum+=*it;
	}
	int f=0;
	for(multiset<LL>::iterator it=s1.begin();it!=s1.end();it++){
		f=1-f;
		if(f)dp[x]+=*it;else dp[x]-=*it;
	}
	s0.clear(),s1.clear();
	if(cnt1&1)dp[x]-=sum;else dp[x]+=sum;
}

int main(){
	cin>>n;
	memset(first,-1,sizeof(first));
	for(int i=2;i<=n;i++){
		int x;
		cin>>x;
		add_edge(x,i);
	}
	dfs(1);
	dfs2(1);
	cout<<(n+dp[1])/2<<endl;
}