#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
 
#define f(i,a,b) for(ll  i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for(ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll  i = a; i < (ll) b ; i+= k )
#define arep(i,a,b,k) for(ll i = a; i >= (ll) b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define sz(a) (ll) a.size()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter   ios::sync_with_stdio(false);cin.tie(0)
 
// policy-based
 
 
 
 
using namespace std;
 
typedef long long ll; // int or ll
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
  
const ll MAX = 1e6 + 20;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
 
vi adj[MAX];
 
ll dp[MAX],sz[MAX];
 
void dfs(ll u){
	vi imp;
	vii par;
	sz[u] = 1;
	dp[u] = 1;
	for(ll v:adj[u]){
		dfs(v);
		sz[u] += sz[v];
		if(sz[v]%2 == 0) imp.push_back(v);
		else par.push_back({2*dp[v]- sz[v],v});
	}
	ll sum = 0,sum1 = 0;
//cout << u << " ::: " << endl;
	for(ll v:imp){
//		cout << v <<" ";
		if(dp[v] <= sz[v] - dp[v])
			dp[u] += dp[v];
		else 
			sum += dp[v],sum1 += sz[v] - dp[v];
	}

	ll t = 1;
 
	sort(all(par));
	for(auto it:par){
		ll v = it.ss;
//		cout << v <<" - ";
		if(t) dp[u] += dp[v];
		else dp[u] += sz[v] - dp[v];
		t = 1-t;
	}
//	cout << endl;
	if(t) dp[u] += sum;
	else dp[u] += sum1;


//	cout << u << " :"  << dp[u] << endl << endl;
 
} 
 
int main(){
	fastio;
	ll n,p;
 	cin >> n;
 	f(i,2,n+1){
 		cin >> p;
 		adj[p].push_back(i);
 	}
 	dfs(1);
 	cout << dp[1] << endl;
    return 0;
}
#define pb push_back
#define mp make_pair
#define fi first
#define se second 
#define all(...) begin(__VA_ARGS__) , end(__VA_ARGS__)
#define boost {ios_base::sync_with_stdio(false); cin.tie(); cout.tie();}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector <int> vi;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
constexpr ll nax = 2e5+6969, INF = 2e9+6969;

int n,dp[nax],last[nax];
bool vis[nax];
vi v[nax];

void dfs(int a, int dad) 
{
	dp[a] = 1;
	int bad = 0;
	vi t;
	for(auto e: v[a]) 
	{
		if(e == dad) continue;
		dfs(e,a);
		if(last[e]) 
		{
			if(dp[e] <= 0) dp[a] += dp[e];
			else bad += dp[e];
		}
		else t.pb(dp[e]);
	}
	if(t.size()&1) 
	{
		last[a] = 1;
		dp[a] -= bad;
	}
	else
	{
		last[a] = 0;
		dp[a] += bad;
	}
	sort(all(t));
	for(int i=0;i<t.size();i++) 
	{
		if(i&1) dp[a] -= t[i];
		else dp[a] += t[i];
	}
}


int main()
{
	scanf("%d", &n);
	for(int i=2;i<=n;i++) 
	{
		int x;
		scanf("%d", &x);
		v[x].pb(i);
		v[i].pb(x);
	}
	dfs(1,1);
	//  for(int i=1;i<=n;i++) cout << dp[i] << " " << last[i] << "\n";
	cout << (n+dp[1])/2 << "\n";
	return 0;
}
