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
d=dict()
s=input()
for i in set(s):
    a=s.index(i)
    d[i]=[a+1,a]
p=0
for j in range(len(s)):
    i=s[j]
    d[i][0]=max(d[i][0],j-d[i][1])
    d[i][1]=j
ans=len(s)
k=len(s)
for i in d.values():
    if i[0]!=0:
        ans=min(ans,max(i[0],k-i[1]))
print(ans)
