#include <bits/stdc++.h>
#define int long long int
using namespace std;
int state[200005];///  1 means change in control
vector <int> graph[200005];
bool visited[200005];
int ch[100005];
void dfs1(int n){
    visited[n] = 1;
    int v = 1;
    ch[n] = 1;
    for(int i = 0;i<graph[n].size();i++){
        if(visited[graph[n][i] ] ){continue;}
        dfs1(graph[n][i] );
        v^= state[graph[n][i] ];
        ch[n]+= ch[graph[n][i] ];
    }
    state[n] = v;
}
int diff(int n ){
    visited[n] = 1;
    vector <int> v0 , v1;
    for(int i = 0;i< graph[n].size()  ;i++){
        if(visited[graph[n][i] ] ){continue;}
        int w = diff(graph[n][i] );
        if(ch[graph[n][i] ]%2 == 1 ){
            v1.push_back(w );
        }
        else{
            v0.push_back(w);
        }
    }
    sort(v0.begin() , v0.end() );sort(v1.begin() , v1.end() );
    reverse(v0.begin() , v0.end() );reverse(v1.begin() , v1.end() );
    int s0p = 0;
    int s0n = 0;
    int ans = -1;
    for(int i = 0;i<v0.size();i++ ){
        if(v0[i]>=0 ){
            s0p+= v0[i];
        }
        else{
            s0n+= v0[i];
        }
    }
    ans+= s0p;
    for(int i = 0;i<v1.size();i++ ){
        if(i%2 == 0 ){
            ans+= v1[i];
        }
        else{
            ans-= v1[i];
        }
    }
    if(v1.size()%2 == 1 ){
        ans+= -s0n;
    }
    else{
        ans+= s0n;
    }
    return ans;
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i = 2;i<= n;i++){
        int  p ;
        cin>>p;
        graph[p].push_back(i);
    }
    dfs1(1);
    for(int i = 1;i<= n;i++){
        visited[i] = 0;
    }
    int ans = diff(1);
    cout<<n - (n+ans)/2;
}
//#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 998244353
#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);
  }
}
vector<vector<int>> g ;

pair<int,pair<int,bool>> dfs(int r)
{
   int A,T;
   A=0,T=1;
   if(si(g[r])==0)
   {
    return {1,{0,true}};
   }

   int ext_T=0,ext_A=0; 
   vector <pair<int,pair<int,int>>> tt; 
   for(auto c: g[r])
   {
       pair<int,pair<int,bool>> pt =dfs(c);
       if(pt.ss.ss)
       {
          tt.pb({pt.ff-pt.ss.ff,{pt.ff,pt.ss.ff}});
       }
       else 
       {
           if(pt.ss.ff>=pt.ff)
           {
             A+=pt.ss.ff;
             T+=pt.ff;
           }
           else 
           {
            ext_A+=pt.ss.ff;
            ext_T+=pt.ff;

           }

       }
   }
   sort(tt.begin(),tt.end());
   
   if(si(tt)%2==0)
   {
     A+=ext_A;
     T+=ext_T;
   }
   else 
   {
     A+=ext_T;
     T+=ext_A;
   }
   for(int i=0;i<si(tt);i+=2)
    A+=tt[i].ss.ss,T+=tt[i].ss.ff;
   for(int i=1;i<si(tt);i+=2)
    A+=tt[i].ss.ff,T+=tt[i].ss.ss;
  bool turn_change= (si(tt)%2==0);
  return {T,{A,turn_change}};

}
void solve()
{

  int n; 
  cin >> n ;
  
  g= vector<vector<int>>(n);
  for(int i=1;i<n;i++)
  {
    int x;
    cin >> x ;
    x-- ;
    g[x].pb(i);
  }
  // root == 1 
  pair<int,pair<int,bool>> pt= dfs(0);
 
  cout << pt.first << 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();

}
