s = list(eval(input()))

t = []

ans = 10**9 + 10



if s.count(s[0]) == len(s):

    print((0))

    exit()



for i in set(s):

    c = i

    j = 0

    n = s

    t = []

    while j >= 0:

        for k in range(1, len(n)):

            if c == n[k-1] and c != n[k]:

                t.append(c)

            elif c != n[k-1] and c == n[k]:

                t.append(c)

            elif c != n[k-1] != n[k]:

                t.append(n[k-1])

            else:

                t.append(n[k])

        if t.count(c) == len(t):

            cnt = j + 1

            if cnt < ans:

                ans = cnt

            break

        else:

            n = t

            t = []

        j += 1



print(ans)
s = eval(input())

ans = []



for ws in s:

    ws = s.split(ws)

    ans.append(max(list(map(len, ws))))



print((min(ans)))
s = list(eval(input()))
t = []
ans = 10**9 + 10
if s.count(s[0]) == len(s):
    print((0))
    exit()
for i in set(s):
    c = i
    j = 0
    n = s
    t = []
    while j >= 0:
        for k in range(1, len(n)):
            if c == n[k - 1] and c != n[k]:
                t.append(c)
            elif c != n[k - 1] and c == n[k]:
                t.append(c)
            elif c != n[k - 1] != n[k]:
                t.append(n[k - 1])
            else:
                t.append(n[k])
        if t.count(c) == len(t):
            cnt = j + 1
            if cnt < ans:
                ans = cnt
            break
        else:
            n = t
            t = []
        j += 1
print(ans)

s = eval(input())
ans = []
for ws in s:
    ws = s.split(ws)
    ans.append(max(list(map(len, ws))))
print((min(ans)))

-s = list(eval(input())) -t = [] -ans = 10**9 + 10 -if s.count(s[0]) == len(s): -    print((0)) -    exit() -for i in set(s): -    c = i -    j = 0 -    n = s -    t = [] -    while j >= 0: -        for k in range(1, len(n)): -            if c == n[k - 1] and c != n[k]: -                t.append(c) -            elif c != n[k - 1] and c == n[k]: -                t.append(c) -            elif c != n[k - 1] != n[k]: -                t.append(n[k - 1]) -            else: -                t.append(n[k]) -        if t.count(c) == len(t): -            cnt = j + 1 -            if cnt < ans: -                ans = cnt -            break -        else: -            n = t -            t = [] -        j += 1 -print(ans) +s = eval(input()) +ans = [] +for ws in s: +    ws = s.split(ws) +    ans.append(max(list(map(len, ws)))) +print((min(ans)))