#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef int ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define autoitr(x,it) for(auto it = x.rbegin(); it != x.rend(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

bool comp(pii a, pii b)
{
    return a.ff-a.ss>b.ff-b.ss; 
}

void dfs(ll curr, ll par, vector<ll> v[], vector<pii> &dp, vector<ll> &tur)
{
    vector<pii> hold[2];
    dp[curr] = mp(0, 1);
    tur[curr] = 0;
    
    autoit(v[curr],it)
    {
        if(*it == par)
            continue;
        dfs(*it, curr, v, dp, tur);
        tur[curr]^=((dp[*it].ff + dp[*it].ss)%2);
        hold[tur[*it]^1].pb(dp[*it]);
    }
    
    vector<pii> temp;
    if(hold[0].size()>0){
        autoit(hold[0],it)
        {
            if(it->ff>=it->ss)
                dp[curr].ff+=it->ff, dp[curr].ss+=it->ss;
            else temp.pb(*it);   
        }
    }
    
    hold[0] = temp;
    if((ll)hold[1].size()>1)
        sort(hold[1].begin(), hold[1].end(), comp);
    ll t11 = 0;
    if(hold[1].size()>0){
        autoit(hold[1],it)
        {
            if(t11 == 0)
                dp[curr].ff+=it->ff, dp[curr].ss+=it->ss;
            else dp[curr].ff+=it->ss, dp[curr].ss+=it->ff;
            t11^=1;
        }
    }
    if(hold[0].size()>0){
        if(t11 == 0){
            autoit(hold[0],it)
                dp[curr].ff+=it->ff, dp[curr].ss+=it->ss;
        }
        else{
            autoit(hold[0],it)
                dp[curr].ff+=it->ss, dp[curr].ss+=it->ff;
        }
    }
    
}

int main()
{
  FAST/**/
  
  ll n;
  cin>>n;
  
  vector<ll> gr[n];
  rep(n-1)
  {
      ll a;
      cin>>a;
      a--;
      ll b = i+1;
      if(a == b)
        continue;
      gr[a].pb(b);
      gr[b].pb(a);
  }
  
  vector<pii> dp(n, mp(0, 0));
  vector<ll> tur(n,0);
  dfs(0, -1, gr, dp, tur);
  cout<<dp[0].ss<<'\n';
  
  
  return 0;
}
   
   
 
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector< int > p(n+1);
    vector< vector< int > > p2c(n+1, vector< int >());
    for(int i = 2; i <= n; i++){
        cin >> p[i];
        p2c[p[i]].push_back(i);
    }

    vector< int > dp(n+1, -1), dpz(n+1, -1);

    auto f = [&](auto f, int v)->void{
        if(p2c[v].size() == 0){
            dp[v] = 1;
            dpz[v] = 1;
            return;
        }
        dp[v] = 1;
        vector< int > vp;
        int pn = 0;
        for(int w: p2c[v]){
            f(f, w);
            if(dp[w] < 0 && dpz[w] == 0){
                dp[v] += dp[w];
            }else if(dpz[w] == 0){
                pn += dp[w];
            }else{
                vp.push_back(dp[w]);
            }
        }
        sort(vp.begin(), vp.end());
        int vs = vp.size();
        for(int i = 0; i < vs; i++) dp[v] += (i%2 == 0 ? vp[i] : -vp[i]);
        dp[v] += (vs%2 == 0 ? pn : -pn);
        dpz[v] = (1-vs%2);
    };
    f(f, 1);
    cout << (n+dp[1])/2 << endl;
}
