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()
l = 0
r = len(s)
d = dict()
count = dict()
for i in s:
    d[i] = False
    count[i] = 0
while r - l > 1:
    mid = (r + l) // 2
    for i in s:
        d[i] = False
        count[i] = 0
    for i in range(mid):
        d[s[i]] = True
        count[s[i]] += 1
    for i in range(len(s) - mid):
        count[s[i]] -= 1
        count[s[i + mid]] += 1
        if count[s[i]] == 0:
            d[s[i]] = False
    for i in d.items():
        if i[1]:
            r = mid
    if r != mid:
        l = mid
print(r)