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
#include <bits/stdc++.h>
int max(int a, int b) {
  if (a > b) return a;
  return b;
}
char s[200000];
int last[50];
int maxx[50];
int ans[50];
int main() {
  int l, i, sum;
  scanf("%s", s);
  l = strlen(s);
  for (i = 1; i <= 26; i++) last[i] = -1;
  for (i = 1; i <= 26; i++) maxx[i] = 0;
  for (i = 1; i <= 26; i++) ans[i] = 0;
  for (i = 0; i < l; i++) {
    maxx[s[i] - 96] = max(i - last[s[i] - 96], maxx[s[i] - 96]);
    last[s[i] - 96] = i;
    ans[s[i] - 96]++;
  }
  int sign = 0;
  for (i = 1; i <= 26; i++)
    if (ans[i] > 1) sign = 1;
  if (sign == 0) {
    printf("%d\n", l / 2 + 1);
    return 0;
  }
  sum = l / 2 + 1;
  for (i = 1; i <= 26; i++) maxx[i] = max(l - last[i], maxx[i]);
  for (i = 1; i <= 26; i++)
    if (ans[i] > 1 && maxx[i] < sum) sum = maxx[i];
  printf("%d\n", sum);
}
