RANDG  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
hide comments
Abhishek:
20160927 14:16:38


hodobox:
20151213 22:05:58
strings could have been longer, the most naive bruteforce solution gets AC in 0.00 :/ 

Jumpy:
20131223 14:59:36
got AC 0.00 sec but not content with that still looking forward to new logic.... 

Andrey Maksimenko:
20131211 09:52:46
Nirmal: you should repaint all red squares, so you will get GGGGGGG. 

Nirmal:
20131202 20:32:09
i could't understand third test case.. someone help me .. GGGGRRR 

Trilok Sharma:
20130907 10:58:17
Test Case:


nitish rao:
20130528 17:22:32
@Roy ... can you check my submission and hint me where am i going wrong.. Id:9370526 Last edit: 20130529 03:51:51 
Added by:  Bidhan 
Date:  20121004 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  Topcoder 