To pass the time, Bessie the cow and her friend Elsie like to play a version of a game they once saw at the county fair.
To start, Bessie places three inverted shells on a table and puts a small round pebble under one of them (at least she hopes it is a pebble: she found it on the ground in one of the pastures). Bessie then swaps pairs of shells, while Elsie tries to guess where the pebble is.
In the standard version of the game that the cows saw at the fair, the player could see the initial location of the pebble and had to guess its final location after all the swaps.
The cows, however, like to play a version in which Elsie does not know the initial location of the pebble and makes a guess after every swap. Bessie, who knows the right answers, gives Elsie a score at the end equal to the number of her correct guesses.
Given the swaps and the guesses, but not the initial location of the pebble, determine the highest score Elsie could have earned.
The first line contains an integer n~(1 \le n \le 100) — the number of swaps. Each of the next lines describes one step of the game and contains three integers , and g~(1 \le a, b, g \le 3, a \ne b): Bessie swapped shells and , and then Elsie guessed that the pebble was under shell .
Print one integer — the maximum score Elsie could have earned.
Example 1
In the example, Elsie could have earned at most points. If the pebble started under shell , she guesses correctly exactly once (her last guess). If the pebble started under shell , she guesses correctly twice (her first two guesses). If the pebble started under shell , she makes no correct guesses.