#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define eps (double)(1e-9)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int n;
vector<vector<int>> G(100010);

//ret = First - Second
//rに動かした人がplayer == 0, player == 1なら交代

P solve(int r){
    int ret = 1;
    int player = 1, cnt = 0;
    priority_queue<int> que;
    for(auto v : G[r]){
        P now = solve(v);
        if(!now.second && now.first < 0)ret += now.first;
        if(!now.second && now.first > 0)cnt += now.first;
        if(now.second)que.push(-now.first);
    }
    while(!que.empty()){
        int t = -que.top();
        que.pop();
        if(player)ret += t;
        else ret -= t;
        player ^= 1;
    }
    if(player)ret += cnt;
    else ret -= cnt;
    return {ret, player};
}

int main() {
    cin >> n;
    rep(i, n-1){
        int p;
        cin >> p;
        G[p-1].push_back(i+1);
    }
    cout << (n+solve(0).first)/2 << endl;
}
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int sum=0,n;
int dp[101][100001],a[101];
int f(int i, int t){
    if(i==n) return max(t,sum-t);
    if(dp[i][t]!=-1) return dp[i][t];
    int ret=f(i+1,t);
    ret=min(ret,f(i+1,t+a[i]));
    dp[i][t]=ret;
    return ret;
}
int main(){
    ios_base::sync_with_stdio(false);
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    cout<<f(0,0)<<"\n";
    return 0; 
}