#!/usr/bin/env ruby

class Object
  def tapp
    debug = false
    if debug
      require 'PP'
      tap { PP.pp(self, $stderr) }
    else
      self
    end
  end
end

# v = gets.split.map(&:to_i)
# while l = gets
# end
nb = 0
sum = 0
gets.chomp.each_char do |c|
  if c == 'B'
    nb += 1
  else
    sum += nb
  end
end
puts sumacc