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
from collections import defaultdict

def main(s):
    d = {}

    n = len(s)
    for i, c in enumerate(s):
        if c in d:
            delta = i - d[c][1] - 1
            if delta > d[c][0]:
                d[c] = (delta, i)
            else:
                d[c] = (d[c][0], i)
        else:
            delta = i
            d[c] = (delta, i)
    
    for c, (gap, idx) in d.items():
        if gap < n - 1 - idx:
            d[c] = (n - 1 - idx, n)

    return min((c for c, _ in d.values())) + 1

if __name__ == '__main__':
    s = input()
    print(main(s))
