remove [] = []
remove [x] = [x]
remove (x1:x2:xs) =
    if x1 /= x2 then remove xs else x1 : remove (x2:xs)

solve s = f s
  where
    f [] = length s
    f as@(x:xs)
      | all (==x) xs = length s - length as
      | otherwise = f $ remove as

main :: IO ()
main = do
    s <- getLine
    print $ solve s
