// In the name of god
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#define Sort(x) sort(all(x))
#define debug(x) cerr << #x << " : " << x << "\n"
#define use_file freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef string str;

const ll maxn = 3e5 + 5, mod = 1e9 + 7, inf = 1e18 + 7;
ll n, dp[maxn];
vector <ll> adj[maxn];
bool bl[maxn];
void dfs(ll u){
	dp[u] ++;
	bl[u] = 1;
	vector <ll> v0, v1;
	for(ll v : adj[u]){
		dfs(v);
		if(bl[v])bl[u] = 1 - bl[u];
		if(bl[v])v1.pb(dp[v]);
		else v0.pb(dp[v]);
	}
	if(adj[u].size() == 0){
		bl[u] = 1;
		dp[u] = 1;
		return;
	}
	if(v0.size())Sort(v0);
	if(v1.size())Sort(v1);
	if(v0.size())reverse(all(v0));
	if(v1.size())reverse(all(v1));
	while(v0.size()){
		if(v0.back() > 0)break;
		dp[u] += v0.back();
		v0.pop_back();
	}
	bool b = 1;
	while(v1.size()){
		if(b)dp[u] += v1.back();
		else dp[u] -= v1.back();
		v1.pop_back();
		b = 1 - b;
	}
	while(v0.size()){
		if(b)dp[u] += v0.back();
		else dp[u] -= v0.back();
		v0.pop_back();
	}
	
}
int main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for(ll i = 2; i <= n; i ++){
		ll p;
		cin >> p;
		adj[p].pb(i);
	}
	dfs(1);
	for(ll i = 0; i <= n; i ++){
		if(i - (n - i) == dp[1])return cout << i << endl, 0;
	}
}

#include<bits/stdc++.h>
#define LL long long
#define SZ(x) (int)x.size()-1
#define F(i,a,b) for (int i=a;i<=b;++i)
#define DF(i,a,b) for (int i=a;i>=b;--i)
#define pb push_back
#define ms(a,b) memset(a,b,sizeof a)
using namespace std;
int read(){
    char ch=getchar(); int w=1,c=0;
    for (;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
    for (;isdigit(ch);ch=getchar()) c=(c<<3)+(c<<1)+(ch^48);
    return w*c;
}
const int M=2e5+10;
int n,dp[M],sz[M];
vector<int> v[M];
bool cmp(int x,int y){
	return 2*dp[x]-sz[x]<2*dp[y]-sz[y];
}
void dfs(int x){
	sz[x]=dp[x]=1;
	vector<int> t;
	int tmp=1,t0=0,t1=0; 
	F(i,0,SZ(v[x])){
		int y=v[x][i];
		dfs(y);
		if (sz[y]&1){
			t.pb(y);
		}
		else{
			if (2*dp[y]-sz[y]<0){
				tmp+=dp[y];
			}
			else{
				t0+=dp[y];
				t1+=sz[y]-dp[y];
			}
		}
		sz[x]+=sz[y];
	}
	sort(t.begin(),t.end(),cmp);
	F(i,0,SZ(t)){
		int y=t[i];
		if (i&1) tmp+=sz[y]-dp[y];
		else tmp+=dp[y];
	}
	if ((SZ(t)+1)&1) tmp+=t1;
	else tmp+=t0;
	dp[x]=tmp;
//	cout<<x<<" "<<dp[x]<<" "<<sz[x]<<"\n";
}
int main(){
	n=read();
	F(i,2,n){
		int x=read();
		v[x].pb(i);
	}
	dfs(1);
	cout<<dp[1]<<"\n";
    return 0;
}

