var readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal:false
});

var arr = [];
var arr1;
var arr2;
var res=0;
var ***=[];
function getMinOfArray(numArray) {
  return Math.min.apply(null, numArray);
}
rl.on('line', function(line){
  arr=line.split('');
  for(var i=0;i<arr.length;i++){
     arr1 = arr.slice(0, i);
     arr2 = arr.slice(i);
     arr1.forEach(function(item){if(item=='G'){res++}})
     arr2.forEach(function(item){if(item=='R'){res++}})
     ***.push(res);res=0;
  }
     console.log(getMinOfArray(***));
});