#P8080. Cup Holder Allocation in Cinema

    ID: 21263 Type: Default 1000ms 256MiB

Cup Holder Allocation in Cinema

Cup Holder Allocation in Cinema

In a cinema, each row has \(N\) seats. The seats can be either normal seats, denoted by S, or heart seats, denoted by L. Note that heart seats always appear in pairs, i.e. if a seat is marked L, the next seat is also L and they form a pair.

Cup holders are installed on both sides of the row and between every two adjacent seats, except that there is no cup holder between the two seats in a heart seat pair. There are exactly \(N\) customers occupying the \(N\) seats. Your task is to determine the maximum number of people that can use a cup holder.

Explanation: Normally, if every gap had a cup holder, there would be \(N+1\) cup holders. However, for every pair of adjacent heart seats, one cup holder (the one between them) is missing. If there are \(k\) such pairs, the total number of cup holders available is \(N+1-k\). Since each person can only use at most one cup holder and a cup holder can be used by only one person, the answer is \(\min\left(N, N+1-k\right)\).

inputFormat

The input consists of a single line containing a string of characters. The length of the string is \(N\) (the number of seats). Each character is either S for a normal seat or L for a heart seat. It is guaranteed that if a seat is marked L, it always appears in a pair with the adjacent L (i.e. heart seats always come in consecutive pairs).

outputFormat

Output the maximum number of people who can use a cup holder.

sample

SSS
3