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 maxn = 1e5 + 5, maxv = 30, inf = 0x3f3f3f3f;
char a[maxn];
int record[maxv][maxn];
void solve() {
  memset(record, 0, sizeof(record));
  for (int i = 0; i < maxv; ++i) {
    record[i][++record[i][0]] = -1;
  }
  int tmp;
  for (int i = 0; a[i]; ++i) {
    int tmp = a[i] - 'a';
    record[tmp][++record[tmp][0]] = i;
  }
  int last = strlen(a);
  for (int i = 0; i < maxv; ++i) {
    record[i][++record[i][0]] = last;
  }
  int Min = inf;
  for (int i = 0; i < 26; ++i) {
    if (record[i][0] == 1) continue;
    int Max = 0;
    for (int j = 1; j < record[i][0]; ++j) {
      Max = max(Max, record[i][j + 1] - record[i][j]);
    }
    Min = min(Max, Min);
  }
  printf("%d\n", Min);
  return;
}
int main() {
  while (~scanf("%s", a)) solve();
  return 0;
}
