spoj#RANDG. Red And Green

Red And Green

Red & Green 

 

You have several squares arranged in a single row. Each square is currently painted red or green. You can choose any of the squares and paint it over with either color. The goal is that, after painting, every red square is further to the left than any of the green squares. We want you to do it repainting the minimum possible number of squares.

Squares are numbered from left to right. You will be given the initial arrangement as a String, such that character i is 'R' if square i is red or 'G' if square i is green. Print the minimum number of repaints needed to achieve the goal.

 

Input

There will be several test cases. Each test case will contain a string of not more than 50 characters on a separate line. Input is terminated by EOF.

Output

For each test case, print the output on a separate line.

 

Constraints

-Input will contain between 1 and 50 characters, inclusive.

-Each character of input will be either 'R' or 'G'.

 

Sample Input

RGRGR

RRRGGGGG

GGGGRRR

RGRGRGRGRGRGRGRGR

Sample Output

2

0

3

8


Solution & Dataset : Bidhan Roy