program main
implicit None
character*200000::s
integer(8)::k,t,i,n
integer(8),allocatable::a(:)

read *,s
k = len_trim(s)
t = 0

do i = k,1,-1
	if(s(i:i) == "B")then
	t = t + 1
	endif
enddo

if(t == 0)then
	print 101,t
	stop
endif

allocate(a(t))

n = 1
do i = k,1,-1
	if(s(i:i) == "B")then
		a(n) = i
		n = n + 1
	endif
enddo

n = 0
do i = 1,t
	n  = n + k - (a(i)) -(i -1)
enddo

print 101,n
deallocate(a)

101 format(i0)
end program main