main = do
  s <- getLine
  print $ minimum 
    [length $ takeWhile (\t -> not (null t) && (not (all (==c) t)))
        $ iterate (\t -> zipWith (\x y -> if x==c then x else y) t (tail t)) s |
      c <- ['a'..'z']]