count = 0
get_string = gets.chomp
sl = get_string.length
  
# 最初がBなら1
count_b = get_string[0] == 'B' ? 1 : 0

(1..sl-1).each do |num|
  if get_string[num] == 'B'
    count_b += 1
    next
  end

  # Bの文字数を足す
  count += count_b
end

puts count
