s = input()
n = []
#找R和G的分界处,统计每个分界处需要涂的数量,然和取最小的一个
for i in range(len(s)+1):
    n.append(s[0:i].count('G') + s[i:].count('R'))
print(min(n))