We’re preparing your current view and syncing the latest data.
There are n games, each played by two teams. Each game has one winner and one loser. The teams are labeled 1, 2, and 3. For each game, the winner and loser team numbers are given. Determine how many teams have won both their games against the other two teams (i.e., teams which won their games against both opponents).
The first line contains an integer n (1 ≤ n ≤ 100) — the number of games played. Each of the next n lines contains two integers a and b (1 ≤ a, b ≤ 3; a ≠ b), where a is the winner and b is the loser of the respective game.
Print a single integer — the number of teams that have won both their games against the other two teams.
1 ≤ n ≤ 100 1 ≤ a, b ≤ 3 a ≠ b
Example 1
Input
3 1 3 2 3 1 2
Output
1
Explanation
Team 1 won against teams 3 and 2, so only team 1 has won against both its opponents.