import Data.List
main = do
    s <- map (\g -> (head g, length g)) . group <$> getLine
    print . snd $ foldl' solve (0,0) s

solve (b,s) (c,l) | c == 'B' = (b+l,s)
                  | c == 'W' = (b,s+b*l)