s = gets.chomp!.split("")
N = s.length
count = 0
loop do
  flag = 1
  (N - 1).times do |i|
    if s[i] == "B" and s[i + 1] == "W"
      s[i] = "W"
      s[i + 1] = "B"
      count += 1
      flag = 0
    end
  end
  break if flag == 1
end

puts count
