#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int MAXN=1e5+4;
int fir[MAXN],nex[MAXN],to[MAXN],f[MAXN],sz[MAXN],tot;
struct node{
	int x,id;
	bool operator<(const node &i) const{
		return x>i.x;
	}
}st[MAXN];

void add(int u,int v) {
	nex[++tot]=fir[u];
   fir[u]=tot;
   to[tot]=v;
}

void dfs(int u) {
	int i,s1=0,s2=0,top=0;
	sz[u]=f[u]=1;
	for(i=fir[u];i;i=nex[i]) {
      dfs(to[i]);
   }
	for(i=fir[u];i;i=nex[i]) {
		sz[u]+=sz[to[i]];
		if (sz[to[i]]-f[to[i]]>=f[to[i]]&&(sz[to[i]]&1)==0) {
         f[u]+=f[to[i]];
		} else {
			if (sz[to[i]]&1) {
            st[++top]=(node){sz[to[i]]-f[to[i]]*2,to[i]};
         } else {
            s1+=f[to[i]];
            s2+=sz[to[i]]-f[to[i]];
         }
		}
	}
	sort(st+1,st+1+top);
	for(i=1;i<=top;++i) {
		if (i&1) {
         f[u]+=f[st[i].id];
      } else {
         f[u]+=sz[st[i].id]-f[st[i].id];
      }
	}
	if (top&1) {
      f[u]+=s2;
   } else {
      f[u]+=s1;
   }
}

int main() {
	int n, i,u;
   cin>>n;
	for(i=2;i<=n;++i) {
      cin>>u;
		add(u,i);
	}
	dfs(1);
	cout<<f[1]<<"\n";
   return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
// --------------------------------------------------------
template<class T> bool chmax(T& a, const T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T b) { if (b < a) { a = b; return 1; } return 0; }
#define FOR(i,l,r) for (ll i = (l); i < (r); ++i)
#define RFOR(i,l,r) for (ll i = (r)-1; (l) <= i; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define COUNT(c,v) count(ALL(c),(v))
#define SZ(c) ((ll)(c).size())
#define BIT(b,i) (((b)>>(i)) & 1)
#define PCNT(b) __builtin_popcountll(b)
#define CIN(c) cin >> (c)
#define COUT(c) cout << (c) << '\n'
#define debug(x) cerr << "l." << __LINE__ << " : " << #x << " = " << (x) << '\n'
ll llceil(ll a, ll b) { return (a + b - 1) / b; }
string toupper(const string& S) { string T(S); REP(i,SZ(T)) T[i] = toupper(T[i]); return T; }
string tolower(const string& S) { string T(S); REP(i,SZ(T)) T[i] = tolower(T[i]); return T; }
using P = pair<ll,ll>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VVS = vector<VS>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VVVLL = vector<VVLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VVVB = vector<VVB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VVVD = vector<VVD>;
using VLD = vector<ld>;
using VVLD = vector<VLD>;
using VVVLD = vector<VVLD>;
static const double EPS = 1e-10;
static const double PI  = acos(-1.0);
static const ll MOD = 1000000007;
// static const ll MOD = 998244353;
static const ll INF = (1LL << 62) - 1;  // 4611686018427387904 - 1
// --------------------------------------------------------
// #include <atcoder/all>
// using namespace atcoder;

// Editorial AC

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    ll N; cin >> N;
    VVLL G(N);
    FOR(i,1,N-1+1) {
        ll p; cin >> p;
        p--;
        G[p].push_back(i);
    }

    // dp[i] := 頂点 i を根とする部分木において，
    //          双方最善を尽くした場合の先手の相対獲得枚数 (先手-後手)
    VLL dp(N,-INF);
    VLL ds(N,1);  // 頂点 i を根とする部分木の頂点数
    auto rec = [&](auto self, ll u, ll p) -> ll {
        if (dp[u] != -INF) return dp[u];
        ll res = 1;  // 先手の相対獲得枚数
        VLL A;  // 偶数回 & 後手が損しない (<= 0)
        VLL B;  // 偶数回 & 後手が損する   ( > 0)
        VLL C;  // 奇数回
        for (ll v : G[u]) if (v != p) {
            self(self, v, u);
            ds[u] += ds[v];
            if (ds[v] % 2 == 0) {
                (dp[v] <= 0 ? A : B).push_back(dp[v]);
            } else {
                C.push_back(dp[v]);
            }
        }
        res += SUMLL(A);
        SORT(C);
        REP(i,SZ(C)) {
            res += C[i] * (i % 2 == 0 ? 1 : -1);
        }
        res += SUMLL(B) * (SZ(C) % 2 == 0 ? 1 : -1);
        return dp[u] = res;
    };
    ll ans = (N + rec(rec, 0, -1)) / 2;
    COUT(ans);

    return 0;
}
