s = STDIN.gets.chomp

if !s.include?('B')
  puts 0
  exit 0
end

if !s.include?('W')
  puts 0
  exit 0
end

last_index = s.size - 1
sorted = last_index - s.rindex('W')

black_indices = []
s.chars.each_with_index do |char, i|
  if char == 'B'
    black_indices << i
  end
end

if sorted == black_indices.size
  puts 0
  exit 0
end

black_indices = black_indices[0..(black_indices.size - sorted - 1)]

p last_index
p sorted
p black_indices
p last_index - sorted - 1
p black_indices[0..(last_index - sorted - 1)]

sum = 0
black_indices.each do |i|
  sum += last_index - sorted - i
  sorted += 1
end

p sum
