Gastronomic Event

아직 제출이 없습니다시간 제한2초메모리 제한2048 MB

문제

SWERC organizers want to hold a gastronomic event.

The location of the event is a building with nn rooms connected by n1n - 1 corridors (each corridor connects two rooms) so that it is possible to go from any room to any other room.

In each room you have to set up the tasting of a typical Italian dish. You can choose from nn typical Italian dishes rated from 11 to nn depending on how good they are (nn is the best possible rating). The nn dishes have distinct ratings.

You want to assign the nn dishes to the nn rooms so that the number of pleasing tours is maximal. A pleasing tour is a nonempty sequence of rooms so that:

  • Each room in the sequence is connected to the next one in the sequence by a corridor.
  • The ratings of the dishes in the rooms (in the order given by the sequence) are increasing.

If you assign the nn dishes optimally, what is the maximum number of pleasing tours?

입력

The first line contains an integer nn (2n1,000,0002 ≤ n ≤ 1\\,000\\,000) — the number of rooms.

The second line contains n1n - 1 integers p_2p\_2, p_3p\_3, \cdots, p_np\_n (1p_i<i1 ≤ p\_i < i). Each p_ip\_i indicates that there is a corridor between room ii and room p_ip\_i. It is guaranteed that the building has the property that it is possible to go from any room to any other room.

출력

Print the maximum number of pleasing tours.