#include <bits/stdc++.h>
#define ll long long
#define coutp(a) cout << "(" << a.first << ", " << a.second << ")"

using namespace std;

const int mx = 2e5;
int parent[mx + 10], Rank[mx + 10];

int get(int a)
{
    return parent[a] = (parent[a] == a? a: get(parent[a]));
}

void Union(int a, int b)
{
    a = get(a);
    b = get(b);

    if(Rank[a] == Rank[b])
        Rank[a]++;
    
    if(Rank[a] > Rank[b])
        parent[b] = a;
    else
        parent[a] = b;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int tt;
    // cin >> tt;
    tt = 1;
    for(int pp = 0 ; pp < tt ; pp++)
    {
        int n;
        cin >> n;
        int a[n];
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }

        set <int> s;
        for (int i = 0; i < n/2; i++)
        {
            if(a[i] != a[n - i - 1])
            {
                if(parent[a[i]] == 0)
                parent[a[i]] = a[i];
                if(parent[a[n - i - 1]] == 0)
                parent[a[n - i - 1]] = a[n - i - 1];

                s.insert(a[i]);
                s.insert(a[n - i - 1]);

                Union(a[i], a[n - i - 1]);
            }
        }

        set <int> s2;
        for(auto i: s)
        {
            // cout << i << " " << get(i) << endl;
            s2.insert(get(i));
        }

        cout << s.size() - s2.size() << endl;
        
        
    }

}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

vector<int> V[100001];

int f[100001], sz[100001];

void dfs(int pos) {
	f[pos] = -1, sz[pos] = 1;

	int sum = 0;
	vector<int> odd;
	for (int w : V[pos]) {
		dfs(w); sz[pos] += sz[w];
		if (sz[w] & 1) odd.push_back(w);
		else {
			if (f[w] >= 0) f[pos] += f[w];
			else sum += f[w];
		}
	}
	sort(odd.begin(), odd.end(), [&](int a, int b) -> bool {
		return f[a] > f[b];
		});
	bool aoki = false;
	for (int w : odd) {
		f[pos] += (aoki ? -1 : 1) * f[w];
		aoki = !aoki;
	}

	if (odd.size() & 1) f[pos] -= sum;
	else f[pos] += sum;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	int n; cin >> n;
	for (int i = 2; i <= n; i++) {
		int a; cin >> a;
		V[a].push_back(i);
	}

	dfs(1);
	cout << (n - f[1]) / 2;

	return 0;
}