main = do
    s <- getLine
    let abc = filter (`elem` s) ['a'..'z']
    print . minimum $ map (shrink 0 s) abc

shrink k s a | all (== a) s = k
             | otherwise = shrink (k+1) s' a
    where s' = zipWith (\x y -> if x == a || y == a then a else x) s (tail s)