Kill the Werewolf

For each player assumed to be the werewolf, decide whether the villagers can outvote him; count the players who still win.

Medium6GreedyImplementationGame theoryBrute forceNo attempts yetTime limit2sMemory limit512 MB

Problem

In the board game One Night Werewolf, the roles of villager and werewolf are handed out at random. The villagers agree together on one person to kill during the night, and they hope that person is a werewolf. The werewolf poses as a villager so that the person killed is a villager instead.

In the variant Uncertain Werewolf there is exactly one werewolf and the game runs in two phases. In the first phase nobody is sure yet who deserves the vote, so each player names two other players as possible victims. Nobody names himself. After the first phase the werewolf reveals himself. In the second phase every player picks one of his own two names and votes to kill that person. The werewolf picks last, after all the other players have voted.

The werewolf loses if he has more votes than every other player. If the highest vote count is tied, the werewolf wins.

The players other than the werewolf know who he is and vote together, as well as they can, to kill him.

You are given the first-phase names of NN players. For each player, assume that player is the werewolf and decide whether he still wins when everyone else votes optimally. Report how many players win.

Input

The first line contains the number of players NN (3N503 \le N \le 50).

Each of the next NN lines contains two integers aia_i and bib_i, the players that player ii named in the first phase (1ai,biN1 \le a_i, b_i \le N, aibia_i \ne b_i, aiia_i \ne i, biib_i \ne i).

Output

Print one integer on a single line, the number of players that would win the game as the werewolf.