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()

def dominant(string, k):
    if not k in string:
        return len(string) + 1
    else:
        last_pointer = -1
        kmap = []
        for i,x in enumerate(string):
            if x == k:
                gap = i - last_pointer - 1
                last_pointer = i
                kmap.append(gap)
            else:
                pass
        gap = len(string) - last_pointer - 1
        kmap.append(gap)
        return max(kmap) + 1

ans_candidates = []

for x in 'abcdefghijklmnopqrstuvwxyz':
    ans_candidates.append(dominant(s,x))

print(min(ans_candidates))
