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
def main():
	s = input()
	solver(s)

def solver(s):
	n = len(s)
	locs = [-1] * 26
	ks = [n+1] * 26
	for i in range(n):
		c = s[i]
		ind = index(c)
		k = i - locs[ind]
		locs[ind] = i
		maxK = ks[ind]
		if maxK == n + 1 or k > maxK:
			ks[ind] = k
#		print(i, c, ind, k, maxK, ks[ind])

	for i in range(26):
		k = n - locs[i]
		maxK = ks[i]
		if maxK == n + 1 or k > maxK:
			ks[i] = k

	bestK = min(ks)
	print(bestK)

def index(c):
	return ord(c) - ord('a')

#solver('abacaba')
#solver('zzzzz')
# solver('abcdef')
main()