local str = io.read()
local n = #str
local t = {str:byte(1, n)}
for i = 1, n do
  t[i] = t[i] - 96
end
local mincost = 100
for alpha = 1, 26 do
  local prevpos = 0
  local cost = 0
  for i = 1, n do
    if(t[i] == alpha) then
      cost = math.max(cost, i - prevpos - 1)
      prevpos = i
    end
  end
  cost = math.max(cost, n - prevpos)
  mincost = math.min(mincost, cost)
end
print(mincost)
