s = gets.chomp.split("")
ans = 0

0.upto(s.length - 2) do |i|
  if s[i] == "B" && s[i + 1] == "W"
    s[i] = "W"
    s[i + 1] = "B"
    ans += 1

    i.downto(1) do |j|
      if s[j] == "W" && s[j - 1] == "B"
        s[j] = "B"
        s[j - 1] = "W"
        ans += 1
      else
        break
      end
    end
  end
end

puts ans
