Yeonghak likes strawberry milk, chocolate milk, and banana milk. He is a picky drinker, so he fixed the order in which he drinks them.
- The first pack he drinks is strawberry milk.
- After a pack of strawberry milk he drinks one pack of chocolate milk.
- After a pack of chocolate milk he drinks one pack of banana milk.
- After a pack of banana milk he drinks one pack of strawberry milk again.
On his milk trip Yeonghak reached a city full of milk shops. The city is a square grid with side N, and every cell holds one shop. Each shop sells only one of the three kinds.
Yeonghak starts at the northwest cell (1,1) and walks to the southeast cell (N,N). Every move takes him one cell east or one cell south, so he never returns to a shop he has already passed. At each cell on his route he either buys and drinks one pack from that shop or walks past it. The order rule above always holds, and he never drinks two packs in one cell. He may drink at the starting cell and at the final cell.
Find the largest number of packs Yeonghak can drink.