n, *r = map(int, open(0).read().split()) a = [[]for _ in [0] * (n + 1)] for i in range(n - 1): a[r[i]] += i + 1, ans = 0 i = j = n while i > 1: ans += 1 m = n for k in range(i, j + 1): m = min(m, min(a[k] + [n])) j = i - 1 i = m print(ans)