Hoof, Paper, Scissors (Bronze)#10545

Hoof, Paper, Scissors (Bronze)

1 second
128 megabytes
Easy

You have probably heard of the game "Rock, Paper, Scissors." The cows enjoy playing a similar game called "Hoof, Paper, Scissors."

The rules of "Hoof, Paper, Scissors" are simple. Two cows play against each other. They count to three, and then each simultaneously makes a gesture representing either a hoof, a piece of paper, or a pair of scissors. Hoof beats scissors (since a hoof can smash a pair of scissors), scissors beats paper (since scissors can cut paper), and paper beats hoof (since a hoof can get a papercut). For example, if the first cow makes a "hoof" gesture and the second cow makes a "paper" gesture, the second cow wins. Of course, a game can also end in a tie if both cows make the same gesture.

Farmer John watches in fascination as two of his cows play a series of games of "Hoof, Paper, Scissors." Unfortunately, although he can see that the cows are making three distinct types of gestures, he cannot tell which one represents "hoof," which one represents "paper," and which one represents "scissors" (to Farmer John's untrained eye, they all look like variations of "hoof"...).

Not knowing the meaning of the three gestures, Farmer John assigns them the numbers , , and . Perhaps gesture represents "hoof," or perhaps it represents "paper"; the meaning is not clear to him. Given the gestures made by both cows over all games, help Farmer John determine the maximum possible number of games the first cow could have won under some mapping between the numbers and their corresponding gestures.

Input

The first line contains n~(1 \le n \le 100). Each of the next lines contains two integers (each , or ), describing one game from Farmer John's perspective.

Output

Print the maximum number of games the first cow could have won.

Examples

One possible assignment for this sample is = "scissors", = "hoof", and = "paper". Under this assignment, the first cow wins games ("" and ""). No other assignment results in more victories.

Example 1

Loading
Loading