str = gets.chomp
maxCount = str.length - 1
count = 0
changeCount = 0
changeFlag = false

loop do 
  if str[count] == "B" && str[count+1] == "W"
    str[count] = "W"
    str[count+1] = "B"
    changeCount += 1
    changeFlag = true
  end
  count += 1
  if(count >= maxCount && changeFlag == false)
    break
  elsif(count >= maxCount)
    count = 0
    changeFlag = false
  end
end
puts changeCount