s = gets.chomp!.split("")
N = s.length
count = 0
loop do
  tmps = []
  s.each do |content|
    tmps.append(content)
  end
  (N - 1).times do |i|
    if s[i] == "B" and s[i + 1] == "W"
      s[i] = "W"
      s[i + 1] = "B"
      count += 1
      #   pp "s:#{s}"
    end
  end
  #   pp "s:#{s}"
  #   pp "tmps:#{tmps}"
  break if tmps == s
end

puts count
