The Olympic Games in Paris are almost here, and you are thrilled! You and four of your friends managed to get five of the rare tickets for sports climbing, even though all tickets were sold out in less than two hours! While waiting for the games to start, you decide to do something fun to distract yourself from the wait: play your favourite card game.
The deck consists of four standard suits of different colours: silver (), white (), emerald (), and red (), as well as a trump suit in cyan (). That is, cyan cards outrank all other cards. There are cards of each suit, numbered from to . Thus, there are cards in the deck. At the beginning of the game, the deck is randomly distributed among five players, so that each player receives cards.
Before you start playing, you want to organise your cards such that all cards of the same suit are grouped together in increasing order, and the trump suit cards are placed at the end (also in increasing order). When you receive your cards, they are given to you as a sequence. To organise them, you perform a sequence of actions, where in each action you can remove one card from your hand and insert it back into your hand in any position (between any two cards, before the first card, or after the last card).
You cannot help but wonder: what is the minimum number of actions required to organise your hand?
The input consists of two lines. The first line contains the integer (1 \le n \le 10^5). The second line contains space-separated values describing the sequence of cards in your hand. Each value consists of a letter from the set \{S, W, E, R, C\} (representing the card suit), followed by an integer such that 1 \le v \le n (representing the card number).
Print one integer: the minimum number of actions required to organise your hand.
Example 1
Example 2