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

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
#define f first
#define s second
#define nl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MOD = 1e9+7;
template<class T> using pqg = priority_queue<T,vector<T>,greater<T>>;

int n;
vi adj[100001];
int ss[100001];

int dfs(int x){
  vi swap;
  vi same;
  int dif=0;
  int num=1;
  trav(k, adj[x]){
    int p=dfs(k);
    num+=ss[k];
    if(ss[k]%2==1) swap.pb(p);
    else same.pb(p);
  }
  if(sz(swap)%2==0){
    trav(k, same){
      dif+=k;
    }
  }
  else{
    trav(k, same){
      if(k<0) dif+=k;
      else dif-=k;
    }
  }

  sort(all(swap));
  rep(i, 0, sz(swap)-1){
    if(i%2==0) dif+=swap[i];
    else dif-=swap[i];
  }
  ss[x]=num;
  return dif+1;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // freopen("input.txt", "r", stdin); 
  // freopen("output.txt", "w", stdout);

  cin >> n;
  rep(i, 2, n){
    int u; cin >> u;
    adj[u].pb(i);
  }
  int d=dfs(1);
  cout << (n+d)/2;
}
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937/*_64*/ rng(chrono::steady_clock::now().time_since_epoch().count());
#define printArr(arr, n) cerr << #arr << " = ["; for(int i=0; i<(n); i++){if (i) cerr << ", "; cerr << arr[i];} cerr << "]\n"
template<class A> ostream& operator<<(ostream &cout, vector<A> const &v) {cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";};
template<class A, class B> ostream& operator<<(ostream &cout, const pair<A,B> &x) {return cout << "(" <<x.first << ", " << x.second << ")";};
void _print() {cerr << "]\n";}
template <class T, class... V> void _print(T t, V... v) {cerr << t; if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#define fi first
#define se second
#define SZ(x) (int)((x).size())
#define pii pair<int,int>
const int mx = 1e5+5;
vector<int> adj[mx];
int sz[mx], dp[mx];
void dfs(int v)
{
	vector<vector<vector<pii>>> amt(2, vector<vector<pii>>(2));
	vector<pii> alternate;
	sz[v] = 1;
	for (int a : adj[v]) {
		dfs(a);
		sz[v] += sz[a];
		if (dp[a] <= sz[a]/2) {
			int dif = sz[a]-2*dp[a]; //how much + they get
			if (sz[a] % 2 == 0) amt[0][0].push_back({dif,a});
			else {
				amt[0][1].push_back({dif,a});
				alternate.emplace_back(dif,a);
			}
		} else {
			int dif = sz[a]-2*dp[a]; //how much + they get
			if (sz[a] % 2 == 0) amt[1][0].push_back({dif,a});
			else {
				amt[1][1].push_back({dif,a});
				alternate.emplace_back(dif,a);
			}
		}
	}
	for (int q = 0; q < 2; q++) {
		for (int w = 0; w < 2; w++) {
			sort(amt[q][w].begin(), amt[q][w].end());
		}
	}
	int tot = 0;
	for (pii x : amt[0][0]) {
		int a,b;
		tie(a,b) = x;
		int ge = (sz[b]+a)/2;
		tot += ge;
	}
	for (pii x : amt[1][0]) {
		int a,b;
		tie(a,b) = x;
		int ge = (sz[b]+a)/2;
		if (SZ(alternate) % 2 == 0) tot += ge;
		else tot += (sz[b]-ge);
	}
	sort(alternate.rbegin(), alternate.rend());
	for (int q = 0; q < SZ(alternate); q++) {
		int a,b;
		tie(a,b) = alternate[q];
		int ge = (sz[b]+a)/2;
		if (q % 2 == 0) tot += ge;
		else tot += (sz[b]-ge);
	}
	dp[v] = sz[v] - tot;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int q = 2; q <= n; q++) {
		int a;
		cin >> a;
		adj[a].push_back(q);
	}
	dfs(1);
	cout << dp[1] << "\n";
	return 0;
}

