//kapi kapi spaghetti
#include <iostream>
#include <iomanip> //setprecision(12)
#include <algorithm>
#include <functional>
#include <map>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
 
typedef long long ll;
typedef unsigned long long ull;
 
using namespace std;

using pll=pair<ll,ll>;
int main()
{
    ll N;
    cin>>N;
    vector<vector<ll>> edge(N);
    for(ll i=1; i<N; i++)
    {
        ll p;
        cin>>p;
        --p;
        edge[p].push_back(i);
    }
    
    auto solve=[&](auto& solve, pll now)->pll//( vertex, turn(1:first,-1:second) )
    {
        
        ll from=now.first, turn=now.second;
        pll res;
        res.first=1*turn;
        turn*=-1;
        res.second=turn;
        
        vector<pll> w,d,l;
        for(auto to:edge[now.first])
        {
            pll temp=solve(solve,pll(to,-turn));
            if(temp.first>0&&temp.second==turn) w.push_back(temp);
            else if(temp.first<=0&&temp.second==turn) l.push_back(temp);
            else d.push_back(temp);
        }
        
        if(turn==1)
        {
            for(auto a:w) res.first+=a.first;
            sort(d.begin(), d.end(), [](pll a, pll b)
            {
                return a.first>b.first;
            });
            for(ll i=0; i<d.size(); i++)
            {
                res.first+=d[i].first*turn;
                turn*=-1;
            }
            res.second=turn;
            for(auto a:l) res.first+=a.first*turn;
            res.second*=-1;
        }
        else
        {
            for(auto a:l) res.first+=a.first;
            sort(d.begin(), d.end(), [](pll a, pll b)
            {
                return a.first<b.first;
            });
            for(ll i=0; i<d.size(); i++)
            {
                res.first+=d[i].first*(-turn);
                turn*=-1;
            }
            res.second=turn;
            for(auto a:w) res.first+=a.first*(-turn);
            res.second*=-1;
        }
        
        //cout<<from<<": "<<res.first<<" "<<res.second<<endl;
        return res;
    };
    
    pll res=solve(solve,pll(0,1));
    //cout<<res.first<<" "<<res.second<<endl;
    cout<<(N+res.first)/2<<endl;
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;

#define rep(i, n) for(int i = 0, i##_len=(n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((int)(x).size())

void _cin() {} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail) { cin >> head; _cin(forward<Tail>(tail)...); }
#define cin(Type, ...) Type __VA_ARGS__; _cin(__VA_ARGS__)
#define cinv(Type, xs, n) vector<Type> xs(n); rep(i, n) cin >> xs[i]
#define cinv2(Type, xs, ys, n) vector<Type> xs(n), ys(n); rep(i, n) cin >> xs[i] >> ys[i]
#define cinv3(Type, xs, ys, zs, n) vector<Type> xs(n), ys(n), zs(n); rep(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define cinvv(Type, xs, h, w) vector<vector<Type>> xs(h, vector<Type>(w)); rep(i, h) rep(j, w) cin >> xs[i][j]

void print() { cout << endl; }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...); }
template <class Type> void print(vector<Type> &vec) { for (auto& a : vec) { cout << a; if (&a != &vec.back()) cout << " "; } cout << endl; }
template <class Type> void print(vector<vector<Type>> &df) { for (auto& vec : df) { print(vec); } }

void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void yesno(bool b) { cout << (b ? "yes" : "no") << endl; }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a < b) { a = b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;

vector<vector<int>> ch(110000);

int calc(int &T, int &A, int p=0) {
	T = 1;
	A = 0;
	int N = 1;
	if (len(ch[p]) == 0) return N;
	
	vector<tuple<int, int, int, int>> st;
	for (auto c : ch[p]) {
		int t, a;
		int n = calc(t, a, c);
		N += n;
		st.emplace_back((n % 2) ? 1 : (a - t > 0) ? 0 : 2, t - a, t, a);
	}
	sort(all(st));
	int i = 0;
	for (auto [o, s, t, a] : st) {
		if (o) {
			if (i % 2) swap(t, a);
			if (o == 1) i++;
		}
		T += t;
		A += a;
	}
	return N;
}

void Main() {
	cin(int, n);
	for (int i = 1; i < n; i++) {
		cin(int, p);
		p--;
		ch[p].emplace_back(i);
	}
	int t, a;
	calc(t,a);
	print(t);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(16);
	//int t; cin >> t; while (t--)
	Main();
}