import Data.List

main ::  IO ()
main = getLine >>= print . solve . map (== 'B')

solve :: [Bool] -> Int
solve = count 0 0

count :: Int -> Int -> [Bool] -> Int
count acc bc xxs@(_ : _)
    | null rs = acc
    | otherwise = count (acc + bc + n) (bc + n) $ tail rs
    where
        (bs, rs) = span id xxs
        n = length bs 
count acc _ _ = acc