1 //It is made by Awson on 2017.11.3
2 #include <set>
3 #include <map>
4 #include <ctime>
5 #include <cmath>
6 #include <queue>
7 #include <stack>
8 #include <vector>
9 #include <cstdio>
10 #include <string>
11 #include <cstring>
12 #include <cstdlib>
13 #include <iostream>
14 #include <algorithm>
15 #define LL long long
16 #define Max(a, b) ((a) > (b) ? (a) : (b))
17 #define Min(a, b) ((a) < (b) ? (a) : (b))
18 #define sqr(x) ((x)*(x))
19 using namespace std;
20 const int N = 1000;
21
22 int n, a;
23 struct tt {
24 int to, next;
25 }edge[(N<<1)+5];
26 int path[N+5], top;
27 int fa[N+5];
28 struct ss {
29 int u, a;
30 bool operator < (const ss &b) const {
31 return a > b.a;
32 }
33 }q[N+5];
34 bool cover[N+5];
35
36 void dfs(int u, int father, int dep) {
37 q[u].u = u, q[u].a = dep, fa[u] = father;
38 for (int i = path[u]; i; i = edge[i].next)
39 if (edge[i].to != father) dfs(edge[i].to, u, dep+1);
40 }
41 void coverit(int u, int dep) {
42 cover[u] = 1; if (dep == 0) return;
43 for (int i = path[u]; i; i = edge[i].next)
44 coverit(edge[i].to, dep-1);
45 }
46 void add(int u, int v) {
47 edge[++top].to = v;
48 edge[top].next = path[u];
49 path[u] = top;
50 }
51 void work() {
52 scanf("%d", &n);
53 for (int i = 2; i <= n; i++) {
54 scanf("%d", &a); add(a, i); add(i, a);
55 }
56 dfs(1, 0, 1);
57 sort(q+1, q+1+n);
58 int ans = 0;
59 for (int i = 1; i <= n; i++) {
60 if (cover[q[i].u]) continue;
61 ans ++; int a = fa[fa[q[i].u]];
62 if (!a) break;
63 coverit(a, 2);
64 }
65 printf("%d\n", ans);
66 }
67 int main() {
68 work();
69 return 0;
70 }