s = gets.chomp.split("")

bs = s.map.with_index { |c, i| i if c == "B" }.compact
tobe = [*(s.count - bs.count)...s.count]

ans = bs.count.times.inject(0) do |r, i|
  r + tobe[i] - bs[i]
end

puts ans
