//第一题
#include <bits/stdc++.h>

using namespace std;

int getResult(string square)
{
	int minChange = 100;
	int len = square.size();
	if(len == 0) return 0;
	for (int i = 1; i < len; ++i)
	{
		int tmp = 0;
		for (int j = 0; j < i; ++j)
		{
			if(square[j] == 'G')
				tmp++;
		}

		for(int j = len - 1 ; j >= i ; --j)
		{
			if(square[j] == 'R')
				tmp++;
		}
		minChange = minChange > tmp ? tmp : minChange;
	}
	return minChange;

}

int main(){
    string square;
    while(cin >> square)
    {
    	cout << getResult(square) << endl;
    }
    return 0;
}

//第二题
#include <bits/stdc++.h>

using namespace std;

int getDigit(long long x)
{
	int count = 0;
	while(x)
	{
		count++;
		x /= 10;
	}
	return count;
}

long long helper(long long x)
{
	long long count = 0;
	int digit = getDigit(x);
	if(digit < 2)
		return 0;
	
	count += x/100 * 10;
	int y = x % 100;
	for (int i = 10; i <= y; ++i)
	{
		if(i/10 == i%10)
			count++;
	}
	return count;
}

long long getResult(long long l, long long r)
{
	long long count = 0;
	
	count = helper(r) - helper(l-1);
	return count;
}

int main(){
    long long l;
    long long r;
    while(cin >> l >> r)
    {
    	cout << getResult(l,r) << endl;
    }
    return 0;
}