program main
   implicit none
   integer ::i,j,k,le
   character*200000 s
   integer ::counter=0
!   integer,allocatable,dimension(:)::
   read(*,*)s
   le=len_trim(s)
10   continue
     i=le-1
     do i=le-1,1,-1
!                write(*,*)s(i:i),s(i+1:i+1)
        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
        endif
     enddo
   write(*,*)counter
end program main
