s = gets.chomp.chars
dp = Array.new(s.size, 0)
if s[0] == "B"
  dp[0] += 1
end
idx = []
1.step(s.size - 1) do |i|
  if s[i] == "B"
    dp[i] = dp[i - 1] + 1
  else
    dp[i] = dp[i - 1]
    idx << i
  end
end

res = 0
idx.each do |i|
  res += dp[i]
end
puts res