#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#include <complex>
#define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define reps(x, s) for(llint (x) = 0; (x) < (llint)(s).size(); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define all(x) (x).begin(),(x).end()
#define outl(x) cout << x << endl
#define SP << " " << 
#define inf 1e18

using namespace std;

typedef long long llint;
typedef long long ll;
typedef pair<llint, llint> P;

ll n;
vector<ll> G[100005];
ll num[100005];
ll dp[100005];

void dfs(int v)
{
	num[v] = 1;
	for(auto u : G[v]) dfs(u), num[v] += num[u];
	
	vector<ll> vec[2];
	for(auto u : G[v]) vec[num[u]%2].push_back(dp[u]);
	sort(all(vec[0])), reverse(all(vec[0]));
	sort(all(vec[1])), reverse(all(vec[1]));
	
	dp[v] = -1;
	reps(i, vec[0]) if(vec[0][i] >= 0) dp[v] += vec[0][i];
	reps(i, vec[1]){
		if(i % 2 == 0) dp[v] += vec[1][i];
		else dp[v] -= vec[1][i];
	}
	reps(i, vec[0]) if(vec[0][i] < 0){
		if(vec[1].size() % 2) dp[v] -= vec[0][i];
		else dp[v] += vec[0][i];
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	ll p;
	rep(i, 2, n){
		cin >> p;
		G[p].push_back(i);
	}
	dfs(1);
	
	//rep(i, 1, n) cout << dp[i] << " "; cout << endl;
	
	cout << (n-dp[1])/2 << endl;
	
	return 0;
}
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::vector;
using ll = long long;

int main() {
	int n;
	cin >> n;
	
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	
	vector<int> cnt(200);
	rep(i, n) cnt[a[i] % 200]++;
	
	ll ans = 0;
	rep(i, 200) ans += (ll)cnt[i] * (cnt[i] - 1) / 2;
	
	cout << ans << '\n';
	
	return 0;
}