#Qua2304. TheBigFatDuck play Game

TheBigFatDuck play Game

Background

TheBigFatDuck: This class is too easy, there's nothing interesting to listen to. Hey, what are you playing? It looks fun.

TheHamster: I'm playing a new game called Tree Game. Do you want to join me for a PVP match?

TheBigFatDuck: Sure.

Description

There is a rooted tree with nn nodes, indexed from 11 to nn. Node 11 is the root. For a node vv (v2)(v ≥ 2), its parent is fvf_v.

The rules of this game are as follows:

  • Initially, each node has a coin, and node 11 has a chess piece.
  • The game is played in turns, with TheHamster going first and TheBigFatDuck going second.
  • In each round:
    • If there is a coin on the node where the chess piece is located (In the following text, we will use xx to represent this node), the current player collects the coin and ends the round.
    • If there is no coin on the node xx:
      • If some of xx's child nodes have coins, the current player chooses one of those child nodes, moves the chess piece there, and ends the round.
      • If none of xx's child nodes have coins, the current player moves the chess piece to the parent node of xx and ends the round. If there is no parent, i.e. x=1x = 1, the game ends.

Both TheBigFatDuck and TheHamster play this game using optimal strategies, which means they always aim to collect coins as much as possible. The task is to determine the maximum number of coins that TheHamster can get.

Format

Input

The first line contains an integer nn, representing the number of nodes in the tree. (1n105)(1 \le n \le 10^5)

The second line contains n1n-1 integers fuf_u (2un)(2 \le u \le n), representing the parent of node uu.

Output

One line containing a single integer, representing the maximum number of coins that TheHamster can get.

Sample

10
1 2 3 4 5 6 7 8 9
10
5
1 2 3 1
2
10
1 1 3 1 3 6 7 6 6
5

Limitations

1 second, 128 MB


TheHamster: I won, hahaha.

Teacher: Hamster, stand up and solve this problem.

TheHamster pushed up his round glasses and looked at the teacher with big curious eyes. She secretly glanced at TheBigFatDuck and lowered her head.

TheBigFatDuck's face showed a smile, and then he raised his hand and stood up: Teacher, I know how to solve this problem. Let me help her.