-- wide-flip.hs --- Wide Flip

-- author: Seong Yong-ju <sei40kr@gmail.com>

solve :: Int -> Int -> Int -> String -> Int
solve _ _ t [] = t
solve _ _ t [_] = t
solve n k t (c:c':cs)
  | c /= c' = solve n (k + 1) (min t $ max k (n - k)) (c' : cs)
  | otherwise = solve n (k + 1) t (c' : cs)

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