function main(input){
    lines = input.split("");

    var count=0;
    var flg=true;
    var flgsub=true;
    while(flg){
        if(lines.length<=1){break;}
        flg=false;
        flgsub=true;
        for(var i=0;i<lines.length-1;i++){
            var a=lines[i];
            var b=lines[i+1];

            if(a=="B" && b=="W"){
                lines[i]="W";
                lines[i+1]="B";
                count++;
                flg=true;
                flgsub=false;
            }else if(flgsub){
                if(a=="W"){
                    lines.shift();
                    i--;
                    if(b=="W"){
                        lines.shift();
                        i++;
                    }
                }
            }
            console.log(lines);
            console.log(count);
        }
    }

    console.log(count);
}

main(require('fs').readFileSync('/dev/stdin','utf8'));
