import Prelude
import Data.List

differencepre :: [Int]->[Int]
differencepre [x]=[]
differencepre (x:y:ys)=(y-x-1):(differencepre (y:ys))

difference list = (head list):(differencepre list)

func1 :: Char->String->Int
func1 c s = maximum $ difference $ (elemIndices c s)++[length s]

func2 :: String -> Int
func2 s = minimum $ [func1 x s|x<-s]

main :: IO ()
main = do
    -- 文字列の入力
    s <- getLine
    putStrLn $ show $ func2 s

