import Data.ByteString.Char8 (ByteString) import qualified Data.ByteString.Char8 as B main :: IO () main = solve <$> B.getLine >>= print solve :: ByteString -> Int solve s = minimum [x - 1, y] where [x, y] = map B.length $ B.group s