program irreversible_operation
  implicit none
  character(200000) :: s
  integer :: n, i, m = 0
  integer(8) :: x = 0_8
  read(*,*) s
  n = len_trim(s)
  do i = n, 1, -1
    if (s(i:i) == "W") cycle
    x = x+int(n-i-m,8)
    m = m+1
  end do
  write(*,'(i0)') x
end program irreversible_operation