You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c.

You have to find minimum k such that there exists at least one k-dominant character.

Input

The first line contains string s consisting of lowercase Latin letters (1 ≤ |s| ≤ 100000).

Output

Print one number — the minimum value of k such that there exists at least one k-dominant character.

Examples

Input

abacaba


Output

2


Input

zzzzz


Output

1


Input

abcde


Output

3
s = input()

cs = {}
ma = {}
keys = 'abcdefghijklmnopqrstuvwxyz'
for c in keys:
    cs[c] = []
    ma[c] = -1

for i in range(len(s)):
    c = s[i]
    cs[c].append(i)

for c in keys:
    if len(cs[c]) > 0:
        ma[c] = max(cs[c][0]+1, len(s)-cs[c][-1])
    for i in range(1,len(cs[c])):
        if abs(cs[c][i] - cs[c][i-1]) > ma[c]:
            ma[c] = abs(cs[c][i] - cs[c][i-1])

mi = 9999999999
for m in ma.values():
    if m != -1 and m < mi:
        mi = m

print(mi)
