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
import string
from collections import defaultdict
s=input()
window=defaultdict(list)
character_set=string.ascii_lowercase
n,ans=len(s),len(s)
for idx,char in enumerate(character_set):
    prev=-1
    consider=-10**9-7
    for jdx,x in enumerate(s):
        if x==char:
            consider=max(consider,jdx-prev)
            prev=jdx
    consider=max(consider,n-prev)
    if prev!=-1:
        ans=min(ans,consider)
print(ans)



