local s=io.read()
local n=#s
local sable={s:byte(1,n)}

local min=100
for alphabyte=97,122 do
    local before=0
    local counter=0
    for i=1,n do
        if sable[i]==alphabyte then
            counter=math.max(counter,i-before-1)
            before=i
        end
    end
    counter=math.max(counter,n-before)
    min=math.min(min,counter)
end
print(min)