Stephen Query

Simulate N rounds of survival rock paper scissors and report the longest number of consecutive wins by any single player.

Medium4SimulationImplementationArrayInterviewNo attempts yetTime limit2sMemory limit256 MB

Problem

Stephen Query wears number 30 and plays rock paper scissors for a living. Today is the final of the first Grand Luck Championship. Query's team, the Blazing Fist Aces, meets the old western power, the New York Paper Daniels. The player who piles up the longest winning streak in this match takes the prize money together with the honorary title 'Prize Money for Mother's Birthday Award'.

The match runs NN rounds in total, no matter how many players each team has. The format is survival. The player who loses a round is knocked out, and the winner stays on the court and plays the next round. The team that just lost a player sends in a new player for the next round. A drawn round counts as a win for the player who just came in. In the first round both teams send in a new player, and that round always produces a winner, never a draw.

Scissors is 1, rock is 2, and paper is 3. The number of rounds a player wins before being knocked out is that player's streak. Find the longest streak any single player reaches.

Input

The first line has the number of rounds NN. (1N3001 \le N \le 300)

The second line has the NN hands the Blazing Fist Aces play in rounds 1 through NN, separated by spaces.

The third line has the NN hands the New York Paper Daniels play in the same rounds, in the same format.

Each value is 1 (scissors), 2 (rock), or 3 (paper), and the two values played in the first round differ.

Output

Print the longest streak any single player reaches, on one line.