import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import Data.Char
import Data.List

main = do
  input <- BC.getLine
  let x = map digitToInt . BC.unpack $ input
      n = length x
  print $ minimum $ solve n 0 x

solve :: Int -> Int -> [Int] -> [Int]
solve n i (a:[]) = [max (i+1) (n-i-1)]
solve n i (a:b:bs)
  | a == b    = solve n (i+1) (b:bs)
  | otherwise = (max (i+1) (n-i-1)) : (solve n 0 (b:bs))
