#include<bits/stdc++.h> 
#define int long long
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define endl "\n"
using namespace std;

const int max_n = 1e5+100;
const int max_sum = 1e7+100;
const int max_len = 1e6+110;
const int offset = 1e5+10;
const int inf = 1e18;

int n;
vector<int> adj[max_n];
int st[max_n];

struct Node
{
	int first,second,turn;
	Node(){
		first=0;second=0;turn=0;
	}
};

Node dfs(int v){
	st[v]=1;
	vector<Node> c;

	for(int x:adj[v]){
		c.pb(dfs(x));
		st[v]+=st[x];
	}

	sort(c.begin(),c.end(),[](const Node& a,const Node& b)->bool{
		if(a.turn!=b.turn){
			return a.turn<b.turn;
		}else{
			return (a.second-a.first)>(b.second-b.first);
		}
	});

	Node ans;
	ans.turn = (st[v]%2);
	ans.first = 1;

	for(Node x:c){
		if(x.turn==0 && x.second>=x.first){
			ans.second+=x.second;
			ans.first+=x.first;
		}
	}

	int t=0;

	for(Node x:c){
		if(x.turn==1){
			if(t==0){
				ans.second+=x.second;
				ans.first+=x.first;
			}else{
				ans.second+=x.first;
				ans.first+=x.second;
			}

			t = (t+1)%2;
		}
	}

	for(Node x:c){
		if(x.turn==0 && x.second<x.first){
			if(t==1){
				ans.first+=x.second;
				ans.second+=x.first;
			}else{
				ans.first+=x.first;
				ans.second+=x.second;
			}
		}
	}

	return ans;
}

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    for(int i=1;i<n;i++){
    	int p;cin>>p;p--;
    	adj[p].pb(i);
    }

    Node ans = dfs(0);
    cout<<ans.first<<endl;

}
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef _DEBUG
    #define debug(x) cout << #x << ": " << x << std::endl
#else
    #define debug(x)
    #pragma GCC target("avx")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #pragma GCC optimize("O3")
    #pragma GCC optimize("unroll-loops")
#endif
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); ++i)
#define all(x) (x).begin(), (x).end()
constexpr char enl = '\n';
constexpr int INF = 1000000000;  // 1e9
constexpr ll llINF = 1000000000000000000LL;  // 1e18
/*#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
*/

typedef struct node_ {
    vector<int> child;
    int invert;
    int size;
    int first;

    node_() :
        child(vector<int>(0)), invert(-1), size(1), first(-1) {}
} node;

void Main() {
    int n;
    cin >> n;
    vector<node> tree(0);
    tree.reserve(n);
    rep(i, 0, n) tree.emplace_back();
    rep(i, 1, n) {
        int p;
        cin >> p;
        tree[p - 1].child.push_back(i);
        //debug(tree[p - 1].child[tree[p - 1].child.size() - 1]);
    }

    auto get_inv = [&](auto self, int cn) -> pair<int, int> {
        int res1 = 1, res2 = 1;
        for (auto nn : tree[cn].child) {
            auto [a, b] = self(self, nn);
            res1 = (res1 + a) % 2;
            res2 += b;
        }
        tree[cn].invert = res1;
        tree[cn].size = res2;
        return {res1, res2};
    };
    get_inv(get_inv, 0);
    //rep(i, 0, n) debug(tree[i].size);

    auto get_first = [&](auto self, int cn) -> int {
        //debug(cn);
        if (tree[cn].first != -1) return tree[cn].first;
        int res = 0;
        vector<int> minus(0), plus(0), inv(0);
        for (auto nn : tree[cn].child) {
            //debug(cn); debug(nn);
            self(self, nn);
            if (tree[nn].invert == 1) inv.push_back(nn);
            else if (2 * tree[nn].first <= tree[nn].size)
                minus.push_back(nn);
            else
                plus.push_back(nn);
        }
        sort(all(inv), [&](const auto &a, const auto &b) { return 2 * tree[a].first - tree[a].size < 2 * tree[b].first - tree[b].size; });
        for (auto nn : minus) res += tree[nn].size - tree[nn].first;
        if (inv.size() % 2)
            for (auto nn : plus) res += tree[nn].first;
        else
            for (auto nn : plus) res += tree[nn].size - tree[nn].first;
        rep(i, 0, inv.size()) res += i % 2 ? tree[inv[i]].first : tree[inv[i]].size - tree[inv[i]].first;
        return tree[cn].first = tree[cn].size - res;
    };

    cout << get_first(get_first, 0) << endl;
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
}