시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 3 2 2 66.667%

문제

Mark invited some people to join his social network. Some of them invited new people, who invited new people, and so on. Now there are N people in the network, numbered from 1 to N. Mark has decided to remove some people and keep others. There is one restriction: when removing a person, he will also remove the people s/he invited, and the people they invited, and so on. Mark will never remove himself, and we do not allow people to be invited by more than one person. Mark can also decide to not remove anyone.

How many different sets of people can be removed?

입력

The first line contains a single integer N (N ≤ 6), the number of people in the network. Next are N − 1 lines telling us who invited each person. To be precise, line i in this set (1 ≤ i ≤ N − 1) contains a single integer j (with j > i), which indicates that person j is the person who invited person i. Person N is Mark.

출력

Output a single integer, the number of possible sets of people that can be removed.

예제 입력 1

3
3
3

예제 출력 1

4

예제 입력 2

4
3
4
4

예제 출력 2

6