program irreversible_operation
  implicit none
  character(len=200000) :: s
  integer               :: i, j, n
  integer(8)            :: a, b
  read(*,*) s
  n = len_trim(s)
  a = 0
  b = 0
  j = 0
  do i = 1, n
     if (s(i:i) .eq. 'B') then
        a = a + n - j
        b = b + i
        j = j + 1
     end if
  end do
  write(*,'(i0)') a - b
  stop
end program irreversible_operation