#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define FULL(x,y) memset(x,y,sizeof(x))
using namespace std;

const int N=100005;
int n,p;
vector<int> G[N];
int f[N],sz[N];

void dfs(int x) {
	int sum=0;
	vector<int> vec;
	int len=G[x].size();
	for(int i=0;i<len;i++) {
		int v=G[x][i];
		dfs(v);
		sz[x]+=sz[v];
		if (sz[v]%2==0) {
			if (f[v]<0) f[x]+=f[v];
			else sum+=(-f[v]);
		}
		else {
			vec.pb(-f[v]);
		}
	}
	sort(vec.begin(),vec.end(),greater<int>());
	vec.pb(sum);
	for(int i=0;i<vec.size();i++) {
		if ((i&1)==0) f[x]-=vec[i];
		else f[x]+=vec[i];
	}
}

int main() {
	cin>>n;
	for(int i=1;i<=n;i++) {
		sz[i]=1;f[i]=1;
	}
	for(int i=2;i<=n;i++) {
		cin>>p;
		G[p].pb(i);
	}
	dfs(1);
	cout<<(n+f[1])/2;
	return 0;	
}
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#include <bits/stdc++.h>
#include<set>
#include <array>
using namespace std;
#define ll long long
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define con continue
#define ub upper_bound
#define lb lower_bound

#define si(x) int(x.size())
#define sum_all(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
const double pi = 2 * acos(0.0);
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, -1, 0, 1 };

const int dx8[] = { -1, 0, 1, 0,1,1,-1,-1 };
const int dy8[] = { 0, -1, 0, 1,1,-1,1,-1 };

ll min(ll a,ll b)
{
    if(a<b)return a;
    return b; 
}
ll max(ll a,ll b)
{
    if(a>b)return a;
    return b; 
}
ll ceil1(ll a,ll b)
{
    return(a+b-1)/b;
}
void read(vector<ll> & arr)
{
  for(ll i=0;i<si(arr);i++)
    cin >> arr[i];

}

void read_graph(vector<vector<ll>>& g, ll m)
{
  while(m--)
  {
    ll x,y; cin >> x>> y ;
    x--,y--; 
    g[x].pb(y);
    g[y].pb(x);
  }
}
 ll n;
vector<vector<ll>> g ; 
vector<ll> sz ; 

void dfs1(ll r)
{
 
  sz[r]=1; 
 for(auto a:g[r])
 {
     dfs1(a);
     sz[r]+=sz[a]; 
 }
  return ; 
}
pair<ll,ll>  dfs(ll r)
{

  
 vector<pair<ll,ll>> odd; 
 vector<pair<ll,ll>> even1;
 vector<pair<ll,ll>> even2; 

 ll master=1 ;
 ll follower= 0 ; 
 for(auto a: g[r])
 {
   if(sz[a]%2==0)
   {
       auto temp = dfs(a);
      if(temp.ff>temp.ss)  even1.pb(temp);
      else even2.pb(temp);
    
   }
   else 
   {  
      auto temp =dfs(a);
       odd.pb(temp); 

   }
 }

 if(si(odd)%2==0)
  {
     for(auto a: even1 ) master+=a.ff,follower+=a.ss; 
   }
   else 
   {
      for(auto a: even1 ) master+=a.ss,follower+=a.ff; 
   }

   for(auto a: even2 ) master+=a.ff,follower+=a.ss; 

    vector<ll> temp ;
   for(auto a: odd)
   {
     master+= a.ss;
     follower+=a.ss; 
     temp.pb(a.ff-a.ss);
   } 
   sort(temp.begin(),temp.end()); 

   for(ll i=0;i<temp.size();i++ )
     {
         if(i%2==0)
         {
           master+=temp[i];
         }
         else 
         {
          follower+=temp[i];
         }
     }
  return {master,follower};



}



void solve()
{
 
  cin >> n; 
  g=vector<vector<ll>>(n);
  sz=vector<ll>(n);
  for(ll i=1;i<n;i++)
  { 
     ll x; 
     cin >> x; 
     x--; 
     g[x].pb(i); 
  }
dfs1(0);
 auto temp =dfs(0); 
   cout <<temp.ff << endl; 
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    //int t; cin >> t; while (t--)
    solve();

}
