import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readString = map BS.unpack . BS.words

getString = readString <$> BS.getLine

calc :: String -> Int -> Int
calc [] cur = 0
calc ss cur = cum + calc ss'' cum
  where
    len_ss = length ss
    ss' = dropWhile (== 'B') ss
    len_ss' = length ss'
    cum = if len_ss' == 0
      then 0
      else cur + (len_ss - len_ss')
    ss'' = if len_ss' == 0
      then []
      else tail ss'


main = do
  [s] <- getString
  print $ calc s 0
