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 + 10;
char s[maxn];
int nxt[maxn][26];
bool check(int k) {
  for (int m = 'a'; m <= 'z'; m++) {
    int y = 0;
    int l = strlen(s);
    nxt[l][m - 'a'] = maxn;
    for (int x = l - 1; x >= 0; x--) {
      if (s[x] == m)
        nxt[x][m - 'a'] = x;
      else
        nxt[x][m - 'a'] = nxt[x + 1][m - 'a'];
    }
    for (int a = 0; a < l - k + 1; a++) {
      if (nxt[a][m - 'a'] <= a + k - 1) y++;
    }
    if (y == l - k + 1) return 1;
  }
  return 0;
}
int main() {
  scanf("%s", s);
  int a = strlen(s);
  int r = a, l = 1;
  while (l < r) {
    int m = (l + r) / 2;
    if (check(m) == 1)
      r = m;
    else
      l = m + 1;
  }
  printf("%d\n", l);
  return 0;
}
