#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/hash_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define LL long long
#define int long long
#define ull unsigned long long
#define fi first
#define se second
#define pll pair<LL, LL>
#define pii pair<int, int>
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define SZ(x) ((int)(x.size()))
#define LC (id<<1)
#define RC (id<<1|1)

constexpr int N = 1e6+9;
constexpr int M = 1e9+7;
#ifdef int
constexpr int INF = 0x3f3f3f3f3f3f3f3f;
constexpr int INF2 = 0xcfcfcfcfcfcfcfcf;
#else
constexpr int INF = 0x3f3f3f3f;
constexpr int INF2 = 0xcfcfcfcf;
#endif



signed main() {
    fastio;
    int n;
    cin >> n;
    vector<int> fa(n, -1);
    vector<vector<int>> ch(n);
    for (int i = 1; i < n; i++) {
        cin >> fa[i];
        fa[i]--;
        ch[fa[i]].emplace_back(i);
    }
    vector<int> sz(n, 1);
    // sz*2 + sz-1
    vector<int> dp(n, 0);
    function<void(int)> dfs = [&](int u) {
        dp[u] = 1;
        array<vector<pii>, 2> sub;
        for (int v: ch[u]) {
            dfs(v);
            sz[u] += sz[v];
            sub[sz[v]&1].emplace_back(dp[v], sz[v]-dp[v]);
        }
        sort(sub[0].begin(), sub[0].end(), [](const pii& p1, const pii& p2) {
            return p1.fi-p1.se > p2.fi-p2.se;
        });
        sort(sub[1].begin(), sub[1].end(), [](const pii& p1, const pii& p2) {
            return p1.fi-p1.se < p2.fi-p2.se;
        });
        while (!sub[0].empty() && sub[0].back().fi <= sub[0].back().se) {
            dp[u] += sub[0].back().fi;
            sub[0].pop_back();
        }
        while (!sub[0].empty()) {
            if (SZ(sub[1]) & 1)
                dp[u] += sub[0].back().se;
            else
                dp[u] += sub[0].back().fi;
            sub[0].pop_back();
        }
        for (int i = 0; i < SZ(sub[1]); i++) {
            if (i & 1) dp[u] += sub[1][i].se;
            else dp[u] += sub[1][i].fi;
        }
    };
    dfs(0);
    cout << dp[0] << "\n";
    return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}
template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}

// graph template
// ref : https://ei1333.github.io/library/graph/graph-template.cpp
template<typename T=int>
struct Edge{
    int from,to;
    T w;
    int idx;
    Edge()=default;
    Edge(int from,int to,T w=1,int idx=-1):from(from),to(to),w(w),idx(idx){}
    operator int() const{return to;}
};

template<typename T=int>
struct Graph{
    vector<vector<Edge<T>>> g;
    int V,E;
    Graph()=default;
    Graph(int n):g(n),V(n),E(0){}

    size_t size(){
        return g.size();
    }
    void resize(int k){
        g.resize(k);
    }
    inline const vector<Edge<T>> &operator[](int k)const{
        return (g.at(k));
    }
    inline vector<Edge<T>> &operator[](int k){
        return (g.at(k));
    }
    void add_directed_edge(int from,int to,T cost=1){
        g[from].emplace_back(from,to,cost,E++);
    }
    void add_edge(int from,int to,T cost=1){
        g[from].emplace_back(from,to,cost,E);
        g[to].emplace_back(to,from,cost,E++);
    }
    void read(int m,int pad=-1,bool weighted=false,bool directed=false){
        for(int i=0;i<m;i++){
            int u,v;cin>>u>>v;
            u+=pad,v+=pad;
            T w=T(1);
            if(weighted) cin>>w;
            if(directed) add_directed_edge(u,v,w);
            else         add_edge(u,v,w);
        }
    }
};


// 結局小さいのからとらせればいい説
signed main(){
    int n;cin>>n;
    Graph<> g(n);
    for(int i=1;i<n;i++){
        int j;cin>>j;j--;
        g.add_directed_edge(j,i);
    }


    vector<int> dp(n,0);// dp[i] : iの1を取る手順の人の利得
    vector<int> sz(n,0);
    function<void(int)> dfs=[&](int cur){
        int s=1;
        for(auto &e:g[cur]){
            dfs(e);
            s+=sz[e];
        }

        sz[cur]=s;

        int res=1;// A-B
        bool A=false;
        {
            vector<int> ch,no;
            for(auto &e:g[cur]){
                if(sz[e]%2) ch.push_back(dp[e]);
                else        no.push_back(dp[e]);
            }

            sort(ALL(ch));
            sort(ALL(no));

            int chi=0,noi=0;
            while(chi<(int)ch.size() or noi<(int)no.size()){
                // 相手に押し付けたい
                if(noi<(int)no.size() and no[noi]<0){
                    if(!A) res+=no[noi];
                    else   res-=no[noi];
                    noi++;
                }
                else if(chi<(int)ch.size()){
                    if(!A) res+=ch[chi];
                    else   res-=ch[chi];
                    chi++;
                    A^=1;
                }else{
                    if(!A) res+=no[noi];
                    else   res-=no[noi];
                    noi++;
                }
            }
        }
        dp[cur]=res;
    };

    dfs(0);
    cout<<(dp[0]+n)/2<<endl;
    return 0;
}
