You are about to change history!
You have recently been informed of unfortunate tests on Nagato by the Am*ricans. Being a responsible citizen, you have decided to take matters into your own hands and stop the Am*ricans from destroying such a beautiful and majestic ship.
The Un*ted St*tes Armed Forces (made up of those Am*ricans, henceforth known as USAF) has
Your master plan is to immerse the President in anime and manga until he realizes the foolishness of his actions and becomes a weeaboo, after which he will immediately cancel the planned destruction of the Nagato.
You have already gathered a lot of information about the USAF, but you cannot execute your plan yet as some crucial pieces of information are missing. Although you know information such as "these two people form an inferior-superior pair" (that is, one of them is the direct superior of the other), you do not know who is the superior and you do not actually know which person in the USAF (numbered from
Since the President's number is highly classified, you would like to determine the number of unique ranks in the USAF regardless of which of the members
Constraints
Subtask 1 [20%]
Subtask 2 [30%]
Subtask 3 [50%]
Input Specification
The first line of input will have
The next
Output Specification
You should output
Sample Input
3
2 1
2 3
Sample Output
3
2
3
Explanation for Sample Output
The following diagrams show the hierarchy of the USAF for each of the three cases where person 1, 2, and 3 are the President. The star next to each person shows their rank.
Case 1
There are 3 unique ranks: 1, 2, and 3.
Case 2
There are 2 unique ranks: 1 and 2. Note that both member 1 and member 2 have rank 2, so it's only counted once.
Case 3
There are 3 unique ranks: 1, 2, and 3. Note that this case is symmetrical to the first case.
Everything appearing in this problem is fictitious. Any resemblance to real countries, people, or battleships is purely coincidental. Nagato
Comments
anime suggested: https://www.youtube.com/watch?v=nK7mKlTVxJU&list=PLGR3cWHkCIKPmdVHXlTFKRDignM793AdY
Popular name for this is "tree rerooting" technique. Tutorial