import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B

solve :: B.ByteString -> Char -> Int
solve bs wb
    | B.null bs || B.all (==wb') bs = 0
    | otherwise = 1 + solve (B.dropWhile (/=wb) bs) wb'
    where
        wb' = if wb == 'W' then 'B' else 'W'

main = do
    bs <- B.getLine
    print $ min (solve bs 'W') (solve bs 'B')