402228: GYM100703 K Word order

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

K. Word ordertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

— It is not about games, — Dragon decided that he should not tell Princess about trainings. — It is necessary to make him want to leave the Castles Valley forever.

Princess sank into reverie again. Every day Prince goes into the world outside the Valley and comes back. What if he just does not see that many things in the big world which could change his life?

— It is better say that nothing will change for him if he leaves the Valley, — Dragon broke off Princess' thoughts.

Princess thought out long before, that she would tell Prince. But Dragon, after he listened to her narration, was sure it could not make Prince want to leave the Valley. He knew Prince quite well and realized that not all of Princess' arguments be treat by Prince as "pro"s.

Let's consider that Princess' narrative is a sequence of arguments. For each argument Dragon knew, if it is "pro", "contra" or neutral.

Dragon offered Princess to modify a sequence of arguments so that the last position of "contra" precedes the first position of "pro".

Dragon was quite considerate and understood that it is difficult to Princess to significantly modify a sequence of arguments at once. For this reason he proposed her to modify a sequence step by step. In each step Princess can swap any two consecutive arguments. Of course, there was still plenty of time until evening (when Prince comes back from his work), but Dragon wants to modify a sequence with minimum number of steps.

Your task is to compute the minimum number of the steps.

Input

The first line contains integer n (2 ≤ n ≤ 100) — number of Princess' arguments.

The second line contains string of n symbols F, A and N, where F corresponds to argument "pro", A corresponds to argument "contra", and N corresponds to the neutral argument.

It is guaranteed that the sequence contains at least one argument "pro" and at least one argument "contra".

Output

In the first line print the only integer — minimum number of steps, which are needed to put an original sequence in the suitable form.

ExamplesInput
6
FNAFNN
Output
2

加入题单

算法标签: