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 __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
#from functools import lru_cache   #use @lru_cache(None)
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')
#
def input(): return sys.stdin.readline()
def mapi(arg=0): return map(int if arg==0 else str,input().split())
#------------------------------------------------------------------

a = input().strip()
n = len(a)
mp = defaultdict(list)
#st = list(set(a))
for i in range(n):
    mp[a[i]].append(i)
for i in a:
    mp[i].append(n)
#print(mp)
#st = [ord(i) for i in st]
res =n//2+1
for c in mp.keys():
    mx = max(mp[c][0]+1,0)
    tmp = mp[c]
    for i,v in enumerate(tmp):
        mx = max(mx,v-tmp[i-1])
    res = min(res,mx)
print(res)
