#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define INF LONG_MAX/3
//#define DIV 1000000007
//#define DIV 998244353

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll N;
vector<ll> to[100005];

//そのノードに飛んだやつを先手とする
//先手、後手、flip
tuple<ll, ll, bool> dfs(ll pos) {
	//ここに来て、tekiがコインを取得し、oreのturnになっている
	ll ore = 0;
	ll teki = 1;
	bool oreturn = true;

	//sen - ato, sen, ato
	vector<tuple<ll, ll, ll> > V;
	ll sensum = 0;
	ll atosum = 0;

	for(ll next: to[pos]) {
		ll sen, ato;
		bool flip;
		tie(sen, ato, flip) = dfs(next);

		if(flip) {
			V.push_back({sen-ato, sen, ato});
		} else {
			if(sen >= ato) {
				//なるべく撮りたい
				ore += sen;
				teki += ato;
			} else {
				//なるべく撮りたくない
				sensum += sen;
				atosum += ato;
			}
		}
	}

	sort(V.rbegin(), V.rend());

	rep(i, V.size()) {
		ll _, sen, ato;
		tie(_, sen, ato) = V[i];
		if(oreturn) {
			ore += sen;
			teki += ato;
		} else {
			ore += ato;
			teki += sen;
		}
		oreturn = !oreturn;
	}
	if(oreturn) {
		return {ore + sensum, teki + atosum, true};
	} else {
		return {ore + atosum, teki + sensum, false};
	}
}


int main(){
	cin >> N;
	rep(i, N-1) {
		ll p;
		cin >> p;p--;
		to[p].push_back(i+1);
	}
	ll sen, ato, _;
	tie(sen, ato, _) = dfs(0);
	cout << ato << endl;
}

#include <iostream>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <random>
#include <cassert>

typedef long long ll;
using namespace std;

constexpr ll mod007 = 1000000007;
constexpr ll mod998 = 998244353;

int N, A[200000];
ll C[200], res;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		C[A[i] % 200]++;
	}
	for (int i = 0; i < 200; i++) {
		res += C[i] * (C[i] - 1) / 2;
	}
	cout << res << endl;
}