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
import math
import heapq
from collections import defaultdict, deque
from decimal import *
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

'''C K-dominant Character'''
s=input()
a=[[] for i in range(26)]
n=len(s)
for i in range(n):
    a[ord(s[i])-97].append(i)

res=math.inf
for k in range(26):
    b=a[k]
    temp=-math.inf
    nb=len(b)
    if nb==0:
        continue
    if nb==1:
        temp=max(b[0]+1,n-b[0])
    else:
        for i,j in enumerate(b):
            if i==0:
                temp=max(temp,b[i]+1)
                temp=max(temp,b[i+1]-b[i])
            elif i==nb-1:
                temp=max(temp,b[i]-b[i-1])
                temp=max(temp,n-b[i])
            else:
                temp=max(temp,b[i]-b[i-1])
                temp=max(temp,b[i+1]-b[i])
    res=min(res,temp)
print(res)
