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

using P = pair<int,int>;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  vector<int> root(n,-1);
  root[0] = 0;
  for (int i=0;i<n-1;i++) {
    int p;
    cin >> p;
    p--;
    g[i+1].emplace_back(p);
    g[p].emplace_back(i+1);
    root[i+1] = p;
  }
  stack<int> st;
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    st.push(now);
    for (int i=0;i<g[now].size();i++) {
      int to = g[now][i];
      if (to != root[now]) {
        q.push(to);
      }
    }
  }
  vector<int> subt(n,1);
  vector<int> suba(n,0);
  vector<int> turn(n,1);
  while (!st.empty()) {
    int now = st.top();
    st.pop();
    vector<P> ps;
    int rett = 0;
    int reta = 0;
    int kt = 0;
    for (int i=0;i<g[now].size();i++) {
      int to = g[now][i];
      if (to == root[now]) continue;
      if (turn[to] == 1) {
        ps.emplace_back(P(subt[to]-suba[to],to));
        kt++;
      }
      else {
        if (subt[to] < suba[to]) {
          subt[now] += subt[to];
          suba[now] += suba[to];
        }
        else {
          rett += subt[to];
          reta += suba[to];
        }
      }
    }
    sort(ps.begin(),ps.end());
    for (int j=0;j<ps.size();j++) {
      P pst = ps[j];
      int ind = pst.second;
      if (j%2 == 0) {
        subt[now] += subt[ind];
        suba[now] += suba[ind];
      }
      else {
        subt[now] += suba[ind];
        suba[now] += subt[ind];
      }
    }
    if (kt%2 == 0) {
      subt[now] += rett;
      suba[now] += reta;
    }
    else {
      subt[now] += reta;
      suba[now] += rett;
    }
    turn[now] = (kt+1)%2;
  }
  cout << subt[0] << endl;
}
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define MP make_pair
#define N 200005
typedef long long LL;

int n, p[N];
int f[N], sz[N];
vector<int> E[N];


void dfs(int x)
{
	++sz[x];
	vector<int> v, v2;
	for (auto &y: E[x]) 
	{
	 	dfs(y);
	 	if (sz[y]&1) v.push_back(f[y]);
	 	else v2.push_back(f[y]);
	 	sz[x] += sz[y];
    }
    sort(v2.begin(), v2.end());
    f[x]++;
    int ss = 0;
    for (auto val: v2)
	{
		if (val < 0) f[x] += val;
		else ss+=val;
	}
	sort(v.begin(), v.end());
	v.push_back(ss);
	int o = 1;
	for (auto val: v)
		f[x] += o*val, o*=-1;
	//cout << x << " " << f[x] << endl;
}
int main()
{
	scanf("%d", &n);
	for (int i = 2; i <= n; ++i)
		scanf("%d", &p[i]), E[p[i]].push_back(i);
	dfs(1);
	cout << (n+f[1])/2<<endl;
	return 0;
}