#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 1e5;

vvint g;

P dfs(int v, int p = -1) {
    vint tmp;
    int score = 1, cnt = 1, penalty = 0;
    for (int n_v : g[v]) {
        if (n_v == p) continue;
        auto p = dfs(n_v, v);
        cnt += p.second;
        if (p.first < 0 && p.second % 2 == 0) score += p.first;
        else if (p.first >= 0 && p.second % 2 == 0) penalty += p.first;
        else tmp.push_back(p.first);
    }
    sort(all(tmp));
    int turn = 1;
    rep(i,tmp.size()) {
        if (turn == 1) score += tmp[i];
        else score -= tmp[i];
        turn *= -1;
    }
    if (turn == 1) score += penalty;
    else score -= penalty;
    return P(score, cnt);
}

int main() {
    int n; cin >> n;
    g.resize(n);
    REP(i,n) {
        int p; cin >> p;
        p--;
        g[i].push_back(p);
        g[p].push_back(i);
    }
    auto p = dfs(0);
    cout << (p.second + p.first) / 2 << endl;
}
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	FOR(y,20) {
		FOR(x,20) cout<<(char)('A'+rand()%8);
		cout<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
