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>
using namespace std;
const int N = 1e5 + 50;
int pre[30];
int minn[30];
char str[N];
int main() {
  int i, j;
  scanf("%s", str);
  int len = strlen(str);
  for (i = 0; i < 30; i++) minn[i] = 0;
  memset(pre, -1, sizeof(pre));
  for (i = 0; i < len; i++) {
    int id = str[i] - 'a';
    minn[id] = max(minn[id], i - pre[id]);
    pre[id] = i;
  }
  for (i = 0; i < 26; i++) {
    minn[i] = max(minn[i], len - pre[i]);
  }
  int res = N;
  for (i = 0; i < 26; i++) {
    if (minn[i] == 0) continue;
    res = min(res, minn[i]);
  }
  printf("%d\n", res);
  return 0;
}
