M - Mount Marathon

Time limit: 3 seconds
Memory limit: 256 megabytes
Languages: MS C# .NET 4.7.2053,GNU G++11 5.1.0 ...

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.

Input

The first line contains an integer $N$ $(1 \leq N \leq 52)$ representing the number of cards in the game. The second line contains $N$ integers $C_1, C_2, ..., C_N$ ($1 \leq C_i \leq 13$ for $i = 1, 2, . . . , N$) indicating the values of the cards in the initial piles, from left to right. Each card value appears at most four times.

Output

Output a single line with an integer indicating the minimum number of piles that it is possible to obtain at the end of the game.

Sample test(s)

Input
6 5 8 6 6 10 4
Output
3
Input
1 13
Output
1
Input
5 2 4 6 8 10
Output
5
Input
11 13 1 1 1 13 7 8 10 4 2 1
Output
4