function main(arg) {
	var src = arg.split("\n")[0].split("")
	var register = []
	var sum_counter = 0
	
	for (;;) {
		var counter = 0
		for (var i = src.length - 1; i > 0; i--) {
			if (src[i-1] === "B" && src[i] === "W") {
				src[i] = "B"
				src[i-1] = "W"
				counter++
			}
		}
		sum_counter += counter
		if (counter === 0) {
			break
		}
	}
	// console.log(loop)
	console.log(sum_counter)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
