program main
  implicit none
  integer(8) :: n, i, blacks, res
  character(200000) :: s
  read (*, *) s
  n = len(trim(s))
  res = 0
  blacks = 0
  do i = 1, n
    if (s(i:i) == "B") then
      blacks = blacks + 1
    else
      res = res + blacks
    end if
  end do
  write (*, "(i0)") res
end program main
