from collections import Counter, deque



s = eval(input())

n = len(s)

d = deque([{char} for char in s])

c = Counter(s)



if s[0] * n == s:

    print((0))

    exit()



for i in range(1, n):

    for j in range(n - i):

        char_j = s[j]

        char_right = s[j + i]

        set_j = d[j]

        if char_right not in set_j:

            set_j.add(char_right)

            c[char_right] += 1

    rightest = d.pop()

    for char in rightest:

        c[char] -= 1

    if max(c.values()) == n - i:

        print(i)

        exit()

print('oops, something wrong')

s = eval(input())

a_z = [chr(i) for i in range(97, 97 + 26)]

ans = len(s)

for alp in a_z:

    cnt = 0

    step = 0

    for char in s:

        if char == alp:

            cnt = max(cnt, step)

            step = 0

        else:

            step += 1

    ans = min(max(cnt, step), ans)

print(ans)

from collections import Counter, deque

s = eval(input())
n = len(s)
d = deque([{char} for char in s])
c = Counter(s)
if s[0] * n == s:
    print((0))
    exit()
for i in range(1, n):
    for j in range(n - i):
        char_j = s[j]
        char_right = s[j + i]
        set_j = d[j]
        if char_right not in set_j:
            set_j.add(char_right)
            c[char_right] += 1
    rightest = d.pop()
    for char in rightest:
        c[char] -= 1
    if max(c.values()) == n - i:
        print(i)
        exit()
print("oops, something wrong")

s = eval(input())
a_z = [chr(i) for i in range(97, 97 + 26)]
ans = len(s)
for alp in a_z:
    cnt = 0
    step = 0
    for char in s:
        if char == alp:
            cnt = max(cnt, step)
            step = 0
        else:
            step += 1
    ans = min(max(cnt, step), ans)
print(ans)

-from collections import Counter, deque - -n = len(s) -d = deque([{char} for char in s]) -c = Counter(s) -if s[0] * n == s: -    print((0)) -    exit() -for i in range(1, n): -    for j in range(n - i): -        char_j = s[j] -        char_right = s[j + i] -        set_j = d[j] -        if char_right not in set_j: -            set_j.add(char_right) -            c[char_right] += 1 -    rightest = d.pop() -    for char in rightest: -        c[char] -= 1 -    if max(c.values()) == n - i: -        print(i) -        exit() -print("oops, something wrong") +a_z = [chr(i) for i in range(97, 97 + 26)] +ans = len(s) +for alp in a_z: +    cnt = 0 +    step = 0 +    for char in s: +        if char == alp: +            cnt = max(cnt, step) +            step = 0 +        else: +            step += 1 +    ans = min(max(cnt, step), ans) +print(ans)