S = STDIN.gets.chomp.split('')

index = 0
cnt = 0
bcnt = 0
bindex = 0
while true
  break if index == S.length

  si = S[index]

  # puts "i:#{index},#{si} cnt: #{cnt} bi: #{bindex} bc: #{bcnt}"
  # puts S.join(',')

  if si == 'B'
    bindex = index if bcnt == 0
    bcnt += 1
  elsif bcnt > 0 # W
    S[index] = 'B'
    S[bindex] = 'W'
    cnt += bcnt
    bindex = bindex+1
    # bcnt -= 1
  end
  index += 1
end

puts cnt
