import Data.List
main=do
    s<-getLine
    print $ sum $ f 0 s
f n s
    | null s = []
    | null ss = []
    | null sss = []
    | otherwise =  ((n+ns) * length ws) : f (n+ns) r
    where
    ss = dropWhile (=='W') s
    (bs,sss) = span (=='B') ss
    (ws,r) = span (=='W') sss
    ns = length bs