import Data.List

maximum' xs = if null xs then 0 else maximum xs

main = do
 s <- getLine
 let alphas = ['a'..'z']
 print (shrink alphas s)

shrink alphas s = minimum $ map (seg s) alphas

seg s c = maximum' $ map length $ words $ map (\c' -> if c'==c then ' ' else c') s