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 = str(raw_input())
t=[]
wyn = []
for x in xrange(26):
    t.append([])
for x in range(0, len(s),+1):
    t[ord(s[x])-97].append(x)
for x in t:
    if len(x) > 0:
        if x[0] != 0:
            x.insert(0,-1)
        x.append(len(s))
for x in t:
    if len(x) != 0:
        tmp_wyn = 0
        maks_tmp = 0
        for y in range(0,len(x)-1,+1):
            tmp_wyn = x[y+1]-x[y]
            if tmp_wyn > maks_tmp:
                maks_tmp = tmp_wyn
        wyn.append(maks_tmp)
wyn = sorted(wyn)
print wyn[0]