#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 2e5+5;

typedef pair <int,int> pii;
#define x first
#define y second

int csub[sz], dp[sz];
vector <int> g[sz];

void dfs(int u) {
   csub[u] = dp[u] = 1;
   vector <pii> od, ev;
   for(int v : g[u]) {
      dfs(v);
      csub[u] += csub[v];
      if(csub[v] & 1) od.emplace_back(csub[v] - 2 * dp[v], v);
      else ev.emplace_back(csub[v] - 2 * dp[v], v);
   }
   sort(od.begin(), od.end(), greater<pii>());
   sort(ev.begin(), ev.end(), greater<pii>());
   int ei = 0, oi = 0;
   for(; ei<ev.size(); ei++) {
      auto v = ev[ei].y;
      if(csub[v] - dp[v] > dp[v]) dp[u] += dp[v];
      else break;
   }
   for(; oi<od.size(); oi++) {
      auto v = od[oi].y;
      if(oi & 1) dp[u] += csub[v] - dp[v];
      else dp[u] += dp[v];
   }
   for(; ei<ev.size(); ei++) {
      auto v = ev[ei].y;
      if(oi & 1) dp[u] += csub[v] - dp[v];
      else dp[u] += dp[v];
   }
}

int main() {
   int n;
   cin >> n;
   for(int i=2; i<=n; i++) {
      int j;
      scanf("%d", &j);
      g[j].push_back(i);
   }
   dfs(1);
   cout << dp[1];
}

#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
int N;
int X[200][3],Ans[200][4];
int G2[10000][10000];
vector<vector<int>>G(10001);
vector<vector<int>>X_vec;

int scoring(vector<vector<int>>&ans){
    double ref=0;
    for(int i=0;i<N;++i){
        if(ans[i][0]<=X[i][0] && X[i][0]<ans[i][2] && ans[i][1]<=X[i][1] && X[i][1]<ans[i][3]){
            int S=(ans[i][2]-ans[i][0])*(ans[i][3]-ans[i][1]);
            ref+=1.0-powf(1.0-(double)min(X[i][2],S)/(double)max(X[i][2],S),2);
        }
    }
    ref/=(double)N;
    return (int)(1000000000*ref);
}

bool overlap(int id,int a,int b,int c,int d){
    for(int i=0;i<N;++i)if(i!=id){
        int x1=Ans[i][0];
        int y1=Ans[i][1];
        int x2=Ans[i][2];
        int y2=Ans[i][3];
        if(max(a,x1)<min(x2,c) && max(b,y1)<min(y2,d)){
            //cout<<"over "<<a<<" "<<x2<<" "<<b<<" "<<y2<<" "<<c<<" "<<x1<<" "<<d<<" "<<y1<<endl;
            return true;
        }
    }
    return false;
}

void greedy(){
    int a,b,c,d,id;
    //面積でソート
    //{id,x,y,r}
    sort(X_vec.rbegin(),X_vec.rend(),[](const vector<int>&a,const vector<int>&b){return a[3]<b[3];});
    //初期解の生成
    for(int n=0;n<N;++n){
        id=X_vec[n][0];
        a=X_vec[n][1];
        b=X_vec[n][2];
        c=a+1;
        d=b+1;
        //答えを記録
        Ans[id][0]=a;
        Ans[id][1]=b;
        Ans[id][2]=c;
        Ans[id][3]=d;
    }

    //どこまで広げられるか見ていく
    for(int n=0;n<N;++n){
        id=X_vec[n][0];
        a=Ans[id][0];
        b=Ans[id][1];
        c=Ans[id][2];
        d=Ans[id][3];

        //右斜め上方向に伸ばす
        int c1=c;
        int b1=b;
        while(!overlap(id,a,b1,c1,d) && c1<10000 && b1>0){
            --b1;
            ++c1;
        }
        //cout<<"1: "<<b<<" "<<b1<<" "<<c<<" "<<c1<<endl;

        //右斜め下方向に伸ばす
        int c2=c;
        int d1=d;
        while(!overlap(id,a,b,c2,d1) && c1<10000 && d1<10000){
            ++c1;
            ++d1;
        }
        if(c!=c1)--c1;
        if(d!=d1)--d1;
        //cout<<"2: "<<c<<" "<<c2<<" "<<d<<" "<<d1<<endl;

        //左斜め上方向に伸ばす
        int a1=a;
        int b2=b;
        while(!overlap(id,a1,b2,c,d) && a1>0 && b2>0){
            --a1;
            --b2;
        }
        if(a!=a1)++a1;
        if(b!=b2)++b2;
        //cout<<"3: "<<a<<" "<<a1<<" "<<b<<" "<<b2<<endl;

        //左斜め下方向に伸ばす
        int a2=a;
        int d2=d;
        while(!overlap(id,a2,b,c,d2) && a2>0 && d2<10000){
            --a2;
            ++d2;
        }
        if(a!=a2)++a2;
        if(d!=d2)--d2;
        //cout<<"4: "<<a<<" "<<a2<<" "<<d<<" "<<d2<<endl;
        //cout<<a1<<" "<<a2<<" "<<b1<<" "<<b2<<" "<<c1<<" "<<c2<<" "<<d1<<" "<<d2<<endl;

        a=max(a1,a2);
        b=max(b1,b2);
        c=min(c1,c2);
        d=min(d1,d2);
        //答えを記録
        Ans[id][0]=a;
        Ans[id][1]=b;
        Ans[id][2]=c;
        Ans[id][3]=d;
    }
}

int main(){
    //入力
    cin>>N;
    int x,y,r;
    for(int i=0;i<N;++i){
        cin>>X[i][0]>>X[i][1]>>X[i][2];
        X_vec.push_back({i,X[i][0],X[i][1],X[i][2]});
        G[X[i][0]].push_back(X[i][1]);
        G2[X[i][0]][X[i][1]]=1;
    }
    for(int i=0;i<N;++i)sort(G[i].begin(),G[i].end());
    //アイディア
    //希望する点の座標を隣接リストで保持する
    //for debug
    //for(int i=0;i<n;++i)cout<<X_vec[i][3]<<endl;
    greedy();

    //出力
    for(int i=0;i<N;++i)cout<<Ans[i][0]<<" "<<Ans[i][1]<<" "<<Ans[i][2]<<" "<<Ans[i][3]<<endl;
}