S = input()
alphabets = [chr(ord('a') + x) for x in range(26)]
ans = 10000
for c in alphabets:
    ans = min(ans, max([len(f) for f in S.split(c)]))
print(ans)

270fc9a4d88f0cc68b9451f0ee5b092c7bde962c
<mask token>

<mask token>
for c in alphabets:
    ans = min(ans, max([len(f) for f in S.split(c)]))
print(ans)

S = input()
alphabets = [chr(ord('a') + x) for x in range(26)]
ans = 10000
for c in alphabets:
    ans = min(ans, max([len(f) for f in S.split(c)]))
print(ans)
