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()
#s = [i for i in s]
dom = {}
lastpos ={}
for i in " abcdefghijklmnopqrstuvwxyz":
    dom[i] = 10000000000000
    lastpos[i] = 0
    
for i, si in enumerate(s):
    if dom[si] > 1000000:
        dom[si] = 0
    dom[si] = max(dom[si], i - lastpos[si])
    lastpos[si] = i
for i in " abcdefghijklmnopqrstuvwxyz":
    dom[i] = max(dom[i], len(s) - lastpos[i])

dom.pop(" ")

print(min(dom.values()))
