function Main(input) {
  input=input.replace("\n","");
  var BW=/BW/;
  var counter=0;
  function operation(){
      input=input.replace("BW",'WB');
      counter++;
      return BW.test(input);
  }
  while(operation()){};
  console.log(counter);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
