main = do
  s <- getLine

  let shrink [] _ _ = 10^9
      shrink s c res | s == replicate (length s) c = res
                     | otherwise = shrink s' c (res+1)
        where
          s' = map (\i -> if s !! i == c || s !! (i+1) == c then c else 'X') [0..(length s - 2)]

      solve [] ans     = ans
      solve (c:cs) ans = solve cs (min ans (shrink s c 0))

  print $ solve ['a'..'z'] (10^9)