import collections

s = eval(input())

a = []

for i in range(26):

    cnt = collections.Counter(s)[chr(i+97)]

    if cnt == 0:

        a.append(len(s))

        continue

    num = 0

    ma = 0

    for j in s:

        if j == chr(i+97):

            ans = num

            ma = max(ma, ans)

            num = 0

        else:

            num += 1

        ans = num

        ma = max(ma, ans)

    a.append(ma)

print((min(a)))
s = eval(input())

a = "qwertyuiopasdfghjklzxcvbnm"

mi = 100

for i in a:

    ma,cnt = 0,0

    for j in s:

        if j != i:

            cnt += 1

        else:

            ma = max(ma, cnt)

            cnt = 0

        ma = max(ma,cnt)

    mi = min(mi,ma)

print(mi)
import collections

s = eval(input())
a = []
for i in range(26):
    cnt = collections.Counter(s)[chr(i + 97)]
    if cnt == 0:
        a.append(len(s))
        continue
    num = 0
    ma = 0
    for j in s:
        if j == chr(i + 97):
            ans = num
            ma = max(ma, ans)
            num = 0
        else:
            num += 1
        ans = num
        ma = max(ma, ans)
    a.append(ma)
print((min(a)))

s = eval(input())
a = "qwertyuiopasdfghjklzxcvbnm"
mi = 100
for i in a:
    ma, cnt = 0, 0
    for j in s:
        if j != i:
            cnt += 1
        else:
            ma = max(ma, cnt)
            cnt = 0
        ma = max(ma, cnt)
    mi = min(mi, ma)
print(mi)

-import collections - -a = [] -for i in range(26): -    cnt = collections.Counter(s)[chr(i + 97)] -    if cnt == 0: -        a.append(len(s)) -        continue -    num = 0 -    ma = 0 +a = "qwertyuiopasdfghjklzxcvbnm" +mi = 100 +for i in a: +    ma, cnt = 0, 0 -        if j == chr(i + 97): -            ans = num -            ma = max(ma, ans) -            num = 0 +        if j != i: +            cnt += 1 -            num += 1 -        ans = num -        ma = max(ma, ans) -    a.append(ma) -print((min(a))) +            ma = max(ma, cnt) +            cnt = 0 +        ma = max(ma, cnt) +    mi = min(mi, ma) +print(mi)