program AGC029A
    implicit none
    integer(8)::i,slen,ans
    character(200000)::S
    read*,S
    slen=len_trim(S)
    ans=0
    do i=2,slen
        if(S(i:i)=="W".and.S(i-1:i-1)=="B")ans=ans+1
    end do

    print'(i0)',ans*2
end program AGC029A