시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB69393864.407%

문제

The famous City Central Zoo houses just two creatures, Zebras and Ocelots. These magical creatures spend their time in a single, tall column, each standing atop the back of the creature below it. Whenever the zoo bell rings, the ocelot lowest in the pile turns into a zebra, and all zebras (if there are any) below that creature simultaneously turn into ocelots. If there is no ocelot in the pile when the bell tolls, then nothing happens. The zookeeper has been watching this interesting process for years. Today, suddenly, he begins to wonder how much longer this can go on. That is, given a pile of zebras and/or ocelots, how many times may the bell toll before there are no more ocelots?

입력

Input consists of a number N in the range 1 to 60, followed by N lines, each of which is a single character, either Z (for zebra) or O (for ocelot). These give the order of the creatures from top (first) to bottom (last).

출력

Output should be a single integer giving the number of times the bell must toll in order for there to be no more ocelots.

예제 입력 1

3
Z
O
Z

예제 출력 1

2

예제 입력 2

4
O
Z
Z
O

예제 출력 2

9

출처

ICPC > Regionals > North America > North Central North America Regional > NCNA 2017 H번

  • 문제를 만든 사람: Larry Pyeatt, Robert Hochberg