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

using ll = long long;
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define POPCOUNT(x) __builtin_popcount(x)
template <typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template <typename T> void chmax(T &a, const T &b) { a = max(a, b); }

const ll INF = 1LL << 60;

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} fastiofastio;

const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

// BEGIN CUT
ll modpow(ll x, ll y, ll m) {
    ll a = 1, p = x;
    while (y > 0) {
        if (y % 2 == 0) {
            p = (p * p) % m;
            y /= 2;
        } else {
            a = (a * p) % m;
            y--;
        }
    }
    return a;
}
// END CUT

int dp[100000][2]; //た or あ

vector<int> G[100000];
int sz[100000];

int dfs(int v) {
    sz[v] = 1;
    for (int to : G[v]) {
        sz[v] += dfs(to);
    }
    return sz[v];
}

void solve(int v) {
    //た のターンだとする
    vector<int> odd, even;
    int ans = 0;
    for (int to : G[v]) {
        solve(to);
        if (sz[to] % 2 == 0)
            even.push_back(dp[to][0] - dp[to][1]);
        else
            odd.push_back(dp[to][0] - dp[to][1]);
        ans += dp[to][1];
    }
    sort(ALL(odd), greater<int>());
    int rest = 0;
    for (int x : even) {
        if (x >= 0)
            ans += x;
        else
            rest += x;
    }
    if (odd.size() % 2 == 0)
        ans += rest;
    for (int i = 0; i < odd.size(); i += 2)
        ans += odd[i];
    dp[v][0] = ans - 1;

    // あ のターン
    odd.clear();
    even.clear();
    ans = rest = 0;
    for (int to : G[v]) {
        if (sz[to] % 2 == 0)
            even.push_back(dp[to][1] - dp[to][0]);
        else
            odd.push_back(dp[to][1] - dp[to][0]);
        ans += dp[to][0];
    }
    sort(ALL(odd));
    for (int x : even) {
        if (x <= 0)
            ans += x;
        else
            rest += x;
    }
    if (odd.size() % 2 == 0)
        ans += rest;
    for (int i = 0; i < odd.size(); i += 2)
        ans += odd[i];
    dp[v][1] = ans + 1;
}

int main() {
    int n;
    cin >> n;
    FOR(i, 1, n) {
        int p;
        cin >> p;
        p--;
        G[p].push_back(i);
    }
    dfs(0);
    solve(0);
    cout << (n + dp[0][1]) / 2 << endl;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    ll a[n]; zep(i, 0, n)cin >> a[i];
    ll cnt[200]; memset(cnt, 0, sizeof(cnt));
    
    ll ans = 0;
    zep(i, 0, n){
        ans += cnt[a[i] % 200];
        cnt[a[i] % 200]++;
    }
    print(ans)

    return 0;
}