#include<bits/stdc++.h>
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define ones(x) __builtin_popcount(x)
#define cout2(x, y) cout << x << " " << y << endl
#define cout3(x, y, z) cout << x << " " << y << " " << z << endl
#define N 200005
using namespace std;
int level[N], deg[N], P[N];
vector<int>L[N];
int DFS(int u, int pd, int l){
level[u] = l;
for(int i = 0, v; i < L[u].size(); i++){
v = L[u][i];
if(v != pd)DFS(v, u, l + 1);
}
}
int main(){
int n, u, v;
scanf("%d", &n);
for(int i = 0; i <= n; i++)L[i].clear(), deg[i] = 0;
P[1] = -1;
for(int i = 2; i <= n; i++){
scanf("%d", &P[i]);
deg[P[i]]++;
L[i].pb(P[i]);
L[P[i]].pb(i);
}
DFS(1, -1, 0);
set<pair<int, int> >E;
for(int i = 2; i <= n; i++)E.insert(make_pair(-level[i], i));
pair<int, int> e, aux;
int ans = 0;
while(E.size() > 0){
e = (*E.begin());
E.erase(E.begin());
u = e.second;
v = P[u];
//printf("%d %d %d %d\n", u, v, deg[u], deg[v]);
aux = make_pair(-level[v], v);
if(deg[u] >= 2 && deg[v] >= 3 && v != 1 && E.find(aux) != E.end())E.erase(aux), deg[P[v]]--, ans++;
}
printf("%d\n", ans);
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBwYih4KSBwdXNoX2JhY2soeCkKI2RlZmluZSBhbGwoeCkgeC5iZWdpbigpLCB4LmVuZCgpCiNkZWZpbmUgb25lcyh4KSBfX2J1aWx0aW5fcG9wY291bnQoeCkKI2RlZmluZSBjb3V0Mih4LCB5KSBjb3V0IDw8IHggPDwgIiAiIDw8IHkgPDwgZW5kbAojZGVmaW5lIGNvdXQzKHgsIHksIHopIGNvdXQgPDwgeCA8PCAiICIgPDwgeSA8PCAiICIgPDwgeiA8PCBlbmRsCiNkZWZpbmUgTiAyMDAwMDUKCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbGV2ZWxbTl0sIGRlZ1tOXSwgUFtOXTsKd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