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
# -*- 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)