import copy



s = eval(input())



c_list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]



min_loop = len(s)

for c in c_list:

    if s.count(c) == 0:

        continue

    s_ = copy.copy(s)

    new_s = copy.copy(s)

    loop = 0

    while new_s.count(c) != len(new_s):

        len_s_ = len(s_)

        new_s = ""

        for i in range(len_s_ - 1):

            if s_[i] == c or s_[i+1] == c:

                new_s += c

            else:

                new_s += s_[i]

        loop += 1

        s_ = copy.copy(new_s)

    if loop < min_loop:

        min_loop = loop



print(min_loop)



s = eval(input())

c_list = [chr(i) for i in range(97, 123)]

min_loop = len(s)



for c in c_list:

    str_list = s.split(c)

    loop = max(len(str) for str in str_list)

    min_loop = min(min_loop, loop)



print(min_loop)

import copy

s = eval(input())
c_list = [
    "a",
    "b",
    "c",
    "d",
    "e",
    "f",
    "g",
    "h",
    "i",
    "j",
    "k",
    "l",
    "m",
    "n",
    "o",
    "p",
    "q",
    "r",
    "s",
    "t",
    "u",
    "v",
    "w",
    "x",
    "y",
    "z",
]
min_loop = len(s)
for c in c_list:
    if s.count(c) == 0:
        continue
    s_ = copy.copy(s)
    new_s = copy.copy(s)
    loop = 0
    while new_s.count(c) != len(new_s):
        len_s_ = len(s_)
        new_s = ""
        for i in range(len_s_ - 1):
            if s_[i] == c or s_[i + 1] == c:
                new_s += c
            else:
                new_s += s_[i]
        loop += 1
        s_ = copy.copy(new_s)
    if loop < min_loop:
        min_loop = loop
print(min_loop)

s = eval(input())
c_list = [chr(i) for i in range(97, 123)]
min_loop = len(s)
for c in c_list:
    str_list = s.split(c)
    loop = max(len(str) for str in str_list)
    min_loop = min(min_loop, loop)
print(min_loop)

-import copy - -c_list = [ -    "a", -    "b", -    "c", -    "d", -    "e", -    "f", -    "g", -    "h", -    "i", -    "j", -    "k", -    "l", -    "m", -    "n", -    "o", -    "p", -    "q", -    "r", -    "s", -    "t", -    "u", -    "v", -    "w", -    "x", -    "y", -    "z", -] +c_list = [chr(i) for i in range(97, 123)] -    if s.count(c) == 0: -        continue -    s_ = copy.copy(s) -    new_s = copy.copy(s) -    loop = 0 -    while new_s.count(c) != len(new_s): -        len_s_ = len(s_) -        new_s = "" -        for i in range(len_s_ - 1): -            if s_[i] == c or s_[i + 1] == c: -                new_s += c -            else: -                new_s += s_[i] -        loop += 1 -        s_ = copy.copy(new_s) -    if loop < min_loop: -        min_loop = loop +    str_list = s.split(c) +    loop = max(len(str) for str in str_list) +    min_loop = min(min_loop, loop)