#ifdef LOCAL
#pragma warning(disable:4996)
#pragma warning(disable:4244)
#pragma warning(disable:4554)
#define gets gets_s

#endif
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<stack>
#include<queue>
#include<cmath>
#include<vector>
#include<string>
#include<cctype>
#include<cstdio>
#include<bitset>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<assert.h>
#define ll long long
#define cl(a,x) memset((a),(x),sizeof(a))
#define lson 2*i
#define rson 2*i+1
#define sf scanf
#define ull unsigned long long
#define lowbit(x) (x)&(-x)
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pdd pair<double,double>
#define ti tree[i]
#define endl "\n"
#define debug(num) #num << "=" << num << " "
ll q_pow(ll x, ll n, ll mod) { ll ret = 1; while (n) { if (n & 1) ret = x * ret%mod; x = x * x%mod; n >>= 1; }return ret; }
ll __gcd(ll x, ll y) { if (!y) return x; return __gcd(y, x%y); }
ll getbit(ll now) { int cnt = 0; while (now) { cnt++; now -= lowbit(now); }return cnt; }
int dx[] = { -1,1,0,0 };//上下左右
int dy[] = { 0,0,-1,1 };//
using namespace std;
const ll maxn = 1e5 + 10;
const ll INF = 0x3f3f3f3f;
const ll IINF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
int mod = 1e9 + 7;
void add(ll &a, ll num) { a += num; if (a >= mod) a -= mod; }

vector<int> edge[maxn];
int dp[maxn];
int sz[maxn];
int n;

void dfs(int pos, int fa) {
	sz[pos] = 1;
	dp[pos] = 1;
	int deltaa = 0, deltab = 0;
	vector<int> tmp;

	for (auto to : edge[pos]) {
		if (to == fa) continue;
		dfs(to, pos);
		sz[pos] += sz[to];
		if (sz[to] % 2 == 0) {//子树大小为偶数
			if (sz[to] - dp[to] > dp[to]) {//后手赢的多，必然先走
				dp[pos] += dp[to];
			}
			else {//先手赢的多，看最后谁先走这里
				deltaa += dp[to];
				deltab += sz[to] - dp[to];
			}
		}
		else {//子树大小为奇数，先后手顺序变化
			tmp.emplace_back(to);
		}
	}

	sort(tmp.begin(),tmp.end(),[&](const int x,const int y){
		return sz[x] - dp[x] - dp[x] > sz[y] - dp[y] - dp[y];//谁后手相对先手赢的多，就先走哪个
	});

	for (int i = 0; i < tmp.size(); i++) {
		if (i % 2 == 1) dp[pos] += sz[tmp[i]] - dp[tmp[i]];
		else dp[pos] += dp[tmp[i]];
	}

	if (tmp.size() % 2 == 0) {//说明此时先手边后手，先拿好东西
		dp[pos] += deltaa;
	}
	else dp[pos] += deltab;
	
	//cerr << debug(pos) << debug(dp[pos]) << endl;
}

void solve() {
	cin >> n;
	int num;
	for (int i = 2; i <= n; i++) {
		cin >> num;
		edge[num].emplace_back(i);
		edge[i].emplace_back(num);
	}

	dfs(1, 1);
	cout << dp[1] << endl;
}

signed main(int argc, char *argv[]) {
	if (argc == 2 && strcmp("-debug", argv[1]) == 0) {
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}

	cout << fixed << setprecision(20); ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;

	while (t--) {
		solve();
	}

	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define FOR(i, m, n) for (ll i(m); i < n; i++)
#define DWN(i, m, n) for (ll i(m); i >= n; i--)
#define REP(i, n) FOR(i, 0, n)
#define DW(i, n) DWN(i, n, 0)
#define F(n) REP(i, n)
#define FF(n) REP(j, n)
#define D(n) DW(i, n)
#define DD(n) DW(j, n)
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using tll = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using vtll = vector<tll>;
using gr = vector<vll>;
using wgr = vector<vpll>;
void add_edge(gr&g,ll x, ll y){ g[x].pb(y);g[y].pb(x); }
void add_edge(wgr&g,ll x, ll y, ll z){ g[x].eb(y,z);g[y].eb(x,z); }
template<typename T,typename U>
ostream& operator<<(ostream& os, const pair<T,U>& p) { 
    cerr << ' ' <<  p.x << ',' << p.y; return os; }
template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) { 
    for(auto x: v) os << ' ' <<  x; return os; }
template <typename T> 
ostream& operator<<(ostream& os, const set<T>& v) { 
    for(auto x: v) os << ' ' <<  x; return os; }
template<typename T,typename U>
ostream& operator<<(ostream& os, const map<T,U>& v) { 
    for(auto x: v) os << ' ' <<  x; return os; }
struct d_ {
    template<typename T> d_& operator,(const T& x) {
        cerr << ' ' <<  x; return *this;}
} d_t;
#define dbg(args ...) { d_t,"|",__LINE__,"|",":",args,"\n"; }
#define deb(X ...) dbg(#X, "=", X);
#define EPS (1e-10)
#define INF (1LL<<61)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

ll n;
gr g;

pll rec(ll u) { // ret (what takes Taker, odd/even)
    ll ret = 1, cnt = 1;
    vector<vll> o,e;
    for(auto v: g[u]) {
        auto [val, sz] = rec(v);
        if(sz&1) o.pb({2*val-sz, val,sz-val});
        else e.pb({2*val-sz, val,sz-val});
        cnt += sz;
    }
    sort(all(o));
    F(o.size()) ret += o[i][1+(i&1)];
    F(e.size()) if(e[i][0]<=0) {
        ret += e[i][1];
    } else {
        ret += e[i][1+(o.size()&1)];
    }
    return {ret, cnt};
}

int main(void) {
    ios_base::sync_with_stdio(false);
    cin >> n;
    g = gr(n);
    F(n-1) {
        ll x; cin >> x; x--;
        g[x].pb(i+1);
    }
    cout << rec(0).x << endl;
    return 0;
}
