Mount Marathon is a solitaire game that is played using a regular deck of $52$ cards. To start the gamethe player shuffles the deck and lays $N$ cards face up on the table, forming a straight line of $N$ piles,each pile having a single card. No other cards are used during the rest of the play. Then the playerrepeatedly moves a pile on top of another pile until no more movements are available. The goal of thegame is to end up with the minimum number of piles. When moving a pile $p$ on top of another pile $q$,the following conditions must hold:
- Pile p must be a single-card pile.
- The value of the only card in pile $p$ must be greater than or equal the value of the card that ison top of pile $q$.
- Pile $q$ must be the next pile remaining immediately on the right of pile $p$
Figure (a) below shows a configuration with six cards at the beginning of the game. The playermay move the fifth pile on top of the sixth pile, and then the second pile on top of the third pile; sinceno more movements are available, this would conclude the game with four piles remaining, as it can beseen in figure (b). However, in this case it is possible to end up the game with just the three piles thatappear in figure (c).
Given the initial piles, you must determine the minimum number of piles that it is possible to obtainat the end of the game.