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
st=str(raw_input())
#st=st
n=len(st)
ans=[]
for i in range(0,26):
  #print c
  c=chr(i+97)
  #print c
  lst=[-1]
  for j in range(0,len(st)):
    if st[j]==c:
      lst.append(j)
  #print lst,c
  lst.append(n)
  lst2=[]
  for i in range(0,len(lst)-1):
    lst2.append(lst[i+1]-lst[i])
  #print lst2
  if len(lst2)>0:
    ans.append(max(lst2))
print min(ans)
  
