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

Difficulty: interview

Starter code:

Solutions:
'''input
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
'''
# from time import time
# start = time()
s = input()
# print(len(s))
m = 1000000000
for l in set(s):
	x = set(s.split(l))
	m = min(m, len(max(x, key=len)))
print(m+1)
# print(time() - start)


s = input()
l = 0
r = len(s)
d = dict()
count = dict()
for i in s:
    d[i] = False
    count[i] = 0
while r - l > 1:
    mid = (r + l) // 2
    for i in s:
        d[i] = False
        count[i] = 0
    for i in range(mid):
        d[s[i]] = True
        count[s[i]] += 1
    for i in range(len(s) - mid):
        count[s[i]] -= 1
        count[s[i + mid]] += 1
        if count[s[i]] == 0:
            d[s[i]] = False
    for i in d.items():
        if i[1]:
            r = mid
    if r != mid:
        l = mid
print(r)

# -*- coding: utf-8 -*-

import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys

"""
created by shhuan at 2017/11/9 23:05

"""

S = input()

def check(s, k):
    for w in set(s):
        c = s[:k].count(w)
        if c == 0:
            continue

        for i in range(k, len(s)):
            if s[i-k] == w:
                c -= 1
            if s[i] == w:
                c += 1
            if c == 0:
                break

        if c > 0:
            return True

    return False


lo = 1
hi = len(S)
while lo < hi:
    m = (lo + hi) // 2
    if check(S, m):
        hi = m
    else:
        lo = m+1

print(lo)

import string

s = input()

def max_dist(s, c):
	pos = [-1]
	for i, val in enumerate(s):
		if val == c:
			pos.append(i)
	pos.append(len(s))
	return max(pos[i+1] - pos[i] for i in range(len(pos) - 1))

print(min(max_dist(s, c) for c in string.ascii_lowercase))

s = list(input())

n = len(s)
idx = [[-1] for _ in range(26)]
for i in range(n):
    idx[ord(s[i]) - ord('a')].append(i)
for i in range(26):
    idx[i].append(n)

print(min([max([ls[i + 1] - ls[i] for i in range(len(ls) - 1)]) for ls in idx]))


import math
s=input()
e=set()
for i in s:
    e.add(i)
d={}
for i in e:
    d[i]=[-1]
if len(d)==len(s):
    print(math.ceil((len(s)+1)/2))
    return
a=[]
for i in range(len(s)):
    d[s[i]].append(i)
for i in d:
    d[i].append(len(s))
q=-1
ans=1221243214
for i in d:
    q=-1
    for j in range(1,len(d[i])):
        q=max(q,d[i][j]-d[i][j-1])
    ans=min(q,ans)
print(ans)


s = input()

cs = {}
ma = {}
keys = 'abcdefghijklmnopqrstuvwxyz'
for c in keys:
    cs[c] = []
    ma[c] = -1

for i in range(len(s)):
    c = s[i]
    cs[c].append(i)

for c in keys:
    if len(cs[c]) > 0:
        ma[c] = max(cs[c][0]+1, len(s)-cs[c][-1])
    for i in range(1,len(cs[c])):
        if abs(cs[c][i] - cs[c][i-1]) > ma[c]:
            ma[c] = abs(cs[c][i] - cs[c][i-1])

mi = 9999999999
for m in list(ma.values()):
    if m != -1 and m < mi:
        mi = m

print(mi)


s = str(input())
s = list(s)
n = len(s)
S = set(s)
S = list(S)
N = len(S)
l = [[] for i in range(N)]
r = [-1 for i in range(N)]
for i in range(n):
    for j in range(N):
        if s[i] == S[j]:
            l[j].append(i)
            break
for i in range(N):
    l[i] = [-1] + l[i] + [n]
for i in range(N):
    for j in range(1,len(l[i])):
        r[i] = max(r[i], l[i][j] - l[i][j - 1])
print(min(r))

s = input()
letters = set(s)
ans = len(s)
for ch in letters:
	prev = -1
	max_dist = 0
	for pos in range(len(s)):
		if s[pos] == ch:
			max_dist = max(pos - prev - 1, max_dist)
			prev = pos
	max_dist = max(len(s) - prev - 1, max_dist)
	ans = min(ans, max_dist + 1)
print(ans)



a = input()

S = [[-1] for i in range(26)]

for i in range(len(a)):
    S[ord(a[i])%97] += [i]
for i in range(len(S)):
    S[i] += [len(a)]
min = [-1 for i in range(26)]
#print(S)
for i in range(26):
    for j in range(1, len(S[i])):
        if min[i] < S[i][j] - S[i][j-1]:
            min[i] = S[i][j] - S[i][j-1]
m = 10**6
for i in min:
    if i != -1 and i < m:
        m = i
print(m)

import string

s = input()

ans = len( s ) // 2 + 1

for a in list( string.ascii_lowercase ):
    last = -1
    l = 0
    for i , c in enumerate( list( s ) ):
        if a == c:
            l = max( l, i - last )
            last = i
    l = max( l , len( s ) - last )
    ans = min( ans, l )

print( ans )


s = input()

d = dict()

for i in range(len(s)):
    el = s[i]
    try:
        d[el].append(i)
    except KeyError:
        d[el] = [-1, i]

for i in list(d.keys()):
    d[i].append(len(s))

a = list()
for i in list(d.keys()):
    t = [d[i][j] - d[i][j - 1] for j in range(1, len(d[i]))]
    a.append(max(t))


print(min(min(a), (len(s) + 2) // 2))


S = input()

dp = [[1 for i in range(26)] for j in range(len(S))]

for i in range(len(S)-2,-1,-1):
	dp[i] = [x+1 for x in dp[i+1]]
	dp[i][ord(S[i+1])-ord('a')] = 1

dp2 = [[1 for i in range(26)] for j in range(len(S))]

for i in range(1,len(S)):
	dp2[i] = [x+1 for x in dp2[i-1]]
	dp2[i][ord(S[i-1])-ord('a')] = 1

ans = [0 for i in range(26)]

for i in range(len(S)):
	k = ord(S[i])-ord('a')
	ans[k] = max(ans[k],dp[i][k],dp2[i][k])

out = len(S)
for i in range(26):
	if ans[i]:
		out = min(out,ans[i])
print(out)

line = input()
d = {}
dist = {}
for i in range(len(line)):
    elem = line[i]
    if elem not in d:
        d[elem] = i
        dist[elem] = i + 1
    else:
        dist[elem] = max(dist[elem], i - d[elem])
        d[elem] = i
    #print(dist)
minimum = 999999999
for key in dist:
    dist[key] = max(dist[key], len(line) - d[key])
    minimum = min(minimum, dist[key])
print(minimum)

a = [chr(i) for i in range(ord('a'), ord('z') + 1)]
s = input()
min_dom = len(s)
for letter in a:
    if letter in s:
        cur = s.index(letter) + 1
        last = cur - 1
        ll = cur - 1
        for j in range(ll + 1, len(s)):
            if s[j] == letter:
                cur = max(cur, j - last)
                last = j
        min_dom = min(min_dom, max(cur, len(s) - last))
print(min_dom)

s = input()
l = len(s)

d = [[-1, 0, -1] for i in range(26)]
k = [-1 for i in range(26)]


for i in range(l):
    n = ord(s[i]) - 97
    if d[n][0] == -1:
        d[n][0] = i
        d[n][2] = i
    else:
        d[n][1] = max(d[n][1], i - d[n][0])
        d[n][0] = i

ans = l
for i in range(26):
    if d[i][0] != -1:
        k[i] = max(d[i][2], l - d[i][0] - 1, d[i][1] - 1)    
    if k[i] > -1:
        ans = min(ans, k[i])

print(ans + 1)



s = input()
letters = set(s)
p = dict.fromkeys(letters, [-1, -1])
for i, c in enumerate(s):
    u = max(p[c][1], i - p[c][0])
    p[c] = [i, u]
for value in p.values():
    value[1] = max(len(s) - value[0], value[1])

print(min(i[1] for i in p.values() if i[1] != -1))

s = '!' + input()

m = set(s)
d = {}
d1 = {}
for x in range(1, len(s)):
    if not s[x] in d:
        d[s[x]] = x
    else:
        d[s[x]] = max(d[s[x]], x - s[:x].rindex(s[x]))
    d1[s[x]] = x

for (x, y) in list(d.items()):
    d[x] = max(d[x], len(s) - d1[x])

print(min(d.values()))


s = input()
n = len(s)
l = 0
r = n + 1
while r - l > 1:
    m = (l + r) // 2
    t = set(s[:m])
    d = {}
    for i in range(m):
        if s[i] in d:
            d[s[i]] += 1
        else:
            d[s[i]] = 1
    for i in range(m, n):
        if s[i] in t:
            d[s[i]] += 1
        if s[i - m] in t:
            d[s[i - m]] -= 1
            if d[s[i - m]] == 0:
                t.remove(s[i - m])
    if len(t) > 0:
        r = m
    else:
        l = m
print(r)


def main():
    s = input()
    checked = []
    l = len(s)
    mi = l // 2 + 1
    for i in range(l):
        if s[i] not in checked:
            j = i + 1
            m = i + 1
            t = i
            while j < l:
                while j < l and s[t] != s[j]:
                    j += 1
                if j - t > m:
                    m = j - t
                t = j
                j += 1
            if m < mi:
                mi = m
            checked += [s[i]]
    print(mi)

main()


s=input()
l=[]
for i in s:
    if i not in l:
        l.append(i)
minans=len(s)//2+1
bst=-1
bfn=-1
for i in l:
    j=-1
    ans=0
    st=s.find(i,0)
    fn=len(s)-s[::-1].find(i,0)-1
    
    while s.find(i,j+1)!=-1:
        k=j
        
        j=s.find(i,j+1)
        raz=j-k
        ans=max(ans,raz)
        ans=max(ans,max(st+1,len(s)-fn))
    if ans<minans:
        minans=ans

print(minans)


a = input()
d = 'abcdefghijklmnopqrstuvwxyz'
m = [[-1] for i in range(26)]
n = 0
for i in range(len(a)):
	k = d.index(a[i])
	if len(m[k]) == 1:
		m[k] += [i]
		m[k] += [(m[k][1] - m[k][0])]
	else:
		m[k][0] = m[k][1]
		m[k][1] = i
		if m[k][2] < (m[k][1] - m[k][0]):
			m[k][2] = (m[k][1] - m[k][0])
for i in range(26):
	if len(m[i]) == 3:
		m[i][0] = m[i][1]
		m[i][1] = len(a)
		if m[i][2] < (m[i][1] - m[i][0]):
			m[i][2] = (m[i][1] - m[i][0])
g = []
j = 0
for i in range(26):
	if len(m[i]) == 3:
		k = a[0:m[i][2]]
		n = a[len(a) - m[i][2]::]
		if k.count(d[i]) > 0 and n.count(d[i]) > 0:
			g += [m[i][2]]
j = len(a) // 2 + 1
if len(g) != 0 and j > min(g):
	print(min(g))
else:
	print(j)


s=input()
n=len(s)
k=1
sim=set(s[0])
a=[0]*n
a[0]=1
sim=set(s)
d=dict()
for i in sim:
    d[i]=[-1,1]
for i in range(n):
    d[s[i]][1]=max(d[s[i]][1],i-d[s[i]][0])
    d[s[i]][0]=i
k=10000000
for i in list(d.values()):
    k=min(k,max(n-i[0],i[1]))
print(k)


from collections import defaultdict

s = input()

symbols = defaultdict(list)
for i, c in enumerate(s):
	symbols[c].append(i)

dists = defaultdict(list)
for c, coords in symbols.items():
	deltas = []
	deltas.append(coords[0] + 1)
	for x in range(1, len(coords)):
		deltas.append(coords[x] - coords[x - 1])
	deltas.append(len(s) - coords[-1])
	dists[c] = deltas

# print(dists)

ans = ((len(s) + 2) // 2)
for c in dists.keys():
	if len(dists[c]) > 0:
		ans = min(ans, max(dists[c]))

print(ans)