#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define all(a) a.begin(), a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define range(i, a, b) for (ll i = (a); i < (b); i++)
#define rrange(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << (x) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
template<class T> using pri_s = priority_queue<T, vector<T>, greater<T>>;
template<class T> using pri_b = priority_queue<T>;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr int mod1e9 = 1000000007;
constexpr int mod998 = 998244353;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
constexpr ll ten(int n) { return n ? 10 * ten(n - 1) : 1; };
int dx[] = { 1,0,-1,0,1,1,-1,-1 }; int dy[] = { 0,1,0,-1,1,-1,1,-1 };
void fail() { cout << "-1\n"; exit(0); } void no() { cout << "No\n"; exit(0); }
template<class T> void er(T a) { cout << a << '\n'; exit(0); }
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template<class T> istream &operator >> (istream &s, vector<T> &v) { for (auto &e : v) s >> e; return s; }
template<class T> ostream &operator << (ostream &s, const vector<T> &v) { for (auto &e : v) s << e << ' '; return s; }
template<class T, class U> ostream &operator << (ostream &s, const pair<T, U> &p) { s << p.first << ' ' << p.second; return s; }

struct fastio {
	fastio() {
		cin.tie(0); cout.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(20);
		cerr << fixed << setprecision(20);
	}
}fastio_;

const int N = ten(5) + 10;
vector<vector<int>> graph(N, vector<int>());
vector<int> sz(N, 1), dp(N, 1);

void dfs(int n) {
	vector<P> p;
	for (int i : graph[n]) {
		dfs(i);
		sz[n] += sz[i];
		p.pb({ sz[i] - 2 * dp[i],sz[i] % 2 });
		dp[n] += sz[i] - dp[i];
	}
	sort(all(p), greater<P>());
	int t = 0; int sum = 0;
	for (auto q : p) {
		if (q.first > 0 && q.second == 0) {
			dp[n] -= q.first;
		}
		if (q.second == 1) {
			if (t == 0) {
				dp[n] -= q.first;
			}
			t ^= 1;
		}
		if (q.first < 0 && q.second == 0) {
			sum += q.first;
		}
	}
	if (t == 0) dp[n] -= sum;
}

int main() {
	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int v;
		cin >> v;
		v--;
		graph[v].pb(i);
	}
	dfs(0);
	cout << dp[0] << '\n';
}
#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a; i >-1; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a; i > b; --i)
#define repl(i, a) for (ll i = (ll)0; i < (ll)a; ++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
#define fi first
#define se second
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll mod_998244353 = 998244353;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

//using lll=boost::multiprecision::cpp_int;
//using Double=boost::multiprecision::number<boost::multiprecision::cpp_dec_float<128>>;//仮数部が1024桁
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll mypow(ll x, ll n, const ll &p = -1)
{ //x^nをmodで割った余り

	if (p != -1)
	{
		x =(x%p+p)%p;
	}
	ll ret = 1;
	while (n > 0)
	{
		if (n & 1)
		{
			if (p != -1)
				ret = (ret * x) % p;
			else
				ret *= x;
		}
		if (p != -1)
			x = (x * x) % p;
		else
			x *= x;
		n >>= 1;
	}
	return ret;
}

using namespace std;
//using namespace atcoder;


void solve()
{
	int n;
	cin>>n;
	vector<vector<int>>g(n);
	rep(i,n-1){
		int p;
		cin>>p;
		p--;
		g[i+1].eb(p);
		g[p].eb(i+1);
	}
	//T君:0,A君:1
	auto rec=[&g](auto self,int v,int par=-1)->pair<int,int>{
		int size=1;
		int ret=1;//部分木の根の操作

		int turn=0;//部分木の根でコインを取るプレイヤー基準

		//なるべく小さくしたい
		vector<vector<int>>res(2);
		for(auto x:g[v]){
			if(x!=par){
				auto p=self(self,x,v);
				res[p.second&1].eb(p.first);
				size+=p.second;
			}
		}
		for(auto x:res[0]){//部分木のサイズが偶数で負
			if(x>=0)continue;
			ret+=x;
		}
		sort(all(res[1]));
		for(auto x:res[1]){//部分木のサイズが奇数
			if(!turn)ret+=x;
			else ret-=x;
			turn^=1;
		}
		for(auto x:res[0]){//部分木のサイズが偶数で0以上
			if(x<0)continue;
			if(!turn)ret+=x;
			else ret-=x;
		}
		return {ret,size};
	};
	auto ans=rec(rec,0);
	cout<<(ans.first+n)/2<<"\n";
}

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