program main
   implicit none
   integer(8) ::i,j,k,le
   character*200000 s
   integer(8) ::counter=0,acount=0,dummy
!   integer,allocatable,dimension(:)::
   read(*,*)s
   le=len_trim(s)
   do i=1,le
      if(s(i:i)=="B")then
         acount=acount+i
      else
         counter=counter+1
      endif
   enddo
   write(*,*)(le-counter)*(2*le-counter+1)/2-acount
end program main
