program main
   implicit none
   integer ::i,j,k,le
   character*200000 s
   integer ::counter=0,dcount=1,dummy
!   integer,allocatable,dimension(:)::
   read(*,*)s
   le=len_trim(s)
!10   continue
     i=le-1
 !    do i=le-1,1,-1
   do while(dcount>0)
     dummy=counter;i=le-1
     do while(i>=0)
        if(s(i:i)=="B" .and. s(i+1:i+1)=="W")then
           s(i:i)="W";s(i+1:i+1)="B"
           counter=counter+1;!goto 10
           !i=i+1
        endif
        i=i-1
     enddo
     dcount=counter-dummy
   enddo

   write(*,*)counter
end program main
