#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> v[100000];

pair<int, pair<int, int>> dfs(int x) {
    int p1 = 0, p2 = 0, sa = 0, sb = 0, f = 0, i;
    vector<pair<int, pair<int, int>>> w;
    
    p1++;
    f = 1 - f;
    
    for (i = 0; i < v[x].size(); i++) {
        pair<int, pair<int, int>> p = dfs(v[x][i]);
        int x = p.second.first;
        int y = p.second.second;
        
        if (p.first == 0) {
            if (x <= y) {
                p1 += x;
                p2 += y;
            } else {
                sa += x;
                sb += y;
            }
        } else {
            w.push_back(make_pair(x - y, make_pair(x, y)));
        }
    }
    
    sort(w.begin(), w.end());
    
    for (i = 0; i < w.size(); i++) {
        int x = w[i].second.first;
        int y = w[i].second.second;
        
        if (f == 1) {
            p1 += x;
            p2 += y;
        } else {
            p1 += y;
            p2 += x;
        }
        
        f = 1 - f;
    }
    
    if (f == 1) {
        p1 += sa;
        p2 += sb;
    } else {
        p1 += sb;
        p2 += sa;
    }
    
    return make_pair(f, make_pair(p1, p2));
}

int main() {
    int n, i;
    
    scanf("%d", &n);
    
    for (i = 1; i < n; i++) {
        int p;
        
        scanf("%d", &p);
        
        v[p - 1].push_back(i);
    }
    
    printf("%d\n", dfs(0).second.first);
    
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

// DEBUG BEGIN
#ifdef LOCAL
template<class L, class R> ostream &operator<<(ostream &out, const pair<L, R> &p){
	return out << "(" << p.first << ", " << p.second << ")";
}
template<class Tuple, size_t N> struct TuplePrinter{
	static ostream &print(ostream &out, const Tuple &t){ return TuplePrinter<Tuple, N-1>::print(out, t) << ", " << get<N-1>(t); }
};
template<class Tuple> struct TuplePrinter<Tuple, 1>{
	static ostream &print(ostream &out, const Tuple& t){ return out << get<0>(t); }
};
template<class... Args> ostream &print_tuple(ostream &out, const tuple<Args...> &t){
	return TuplePrinter<decltype(t), sizeof...(Args)>::print(out << "(", t) << ")";
}
template<class ...Args> ostream &operator<<(ostream &out, const tuple<Args...> &t){
	return print_tuple(out, t);
}
template<class T> ostream &operator<<(class enable_if<!is_same<T, string>::value, ostream>::type &out, const T &arr){
	out << "{"; for(auto x: arr) out << x << ", ";
	return out << (arr.empty() ? "" : "\b\b") << "}";
}
template<size_t S> ostream &operator<<(ostream &out, const bitset<S> &b){
	for(auto i = 0; i < S; ++ i) out << b[i];
	return out;
}
void debug_out(){ cerr << "\b\b " << endl; }
template<class Head, class... Tail>
void debug_out(Head H, Tail... T){ cerr << H << ", ", debug_out(T...); }
void debug2_out(){ cerr << "\n"; }
template<class Head, class... Tail>
void debug2_out(Head H, Tail... T){ cerr << "\n"; for(auto x: H) cerr << x << "\n"; debug2_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#define debug2(...) cerr << "[" << #__VA_ARGS__ << "]", debug2_out(__VA_ARGS__)
#else
#define debug(...) 42
#define debug2(...) 42
#endif
// DEBUG END

int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	int n;
	cin >> n;
	vector<vector<int>> adj(n);
	for(auto u = 1; u < n; ++ u){
		int p;
		cin >> p, -- p;
		adj[p].push_back(u);
	}
	vector<int> sz(n, 1);
	function<void(int)> dfs_sz = [&](int u){
		for(auto v: adj[u]){
			dfs_sz(v);
			sz[u] += sz[v];
		}
	};
	dfs_sz(0);
	vector<int> dp(n, 1);
	function<void(int)> dfs = [&](int u){
		int sum = 0;
		array<vector<array<int, 2>>, 2> t;
		for(auto v: adj[u]){
			dfs(v);
			t[sz[v] & 1].push_back({dp[v], sz[v] - dp[v]});
			sum += dp[v];
		}
		if(t[1].empty()){
			dp[u] += sum;
		}
		else{
			if((int)t[1].size() & 1){
				for(auto [x, y]: t[0]){
					dp[u] += min(x, y);
				}
			}
			else{
				for(auto [x, y]: t[0]){
					dp[u] += x;
				}
			}
			sort(t[1].begin(), t[1].end(), [&](auto x, auto y){ return x[0] - x[1] < y[0] - y[1]; });
			for(auto i = 0; i < (int)t[1].size(); ++ i){
				dp[u] += t[1][i][i & 1];
			}
		}
	};
	dfs(0);
	debug(dp);
	cout << dp[0] << "\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////