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;
int a[26][100010];
int b[26];
int main() {
  int n, i, j, k, l, ans;
  string s;
  cin >> s;
  l = s.length();
  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  for (i = 0; i < l; i++) {
    j = (int)(s[i] - 'a');
    a[j][b[j]] = i;
    b[j]++;
  }
  ans = 0x3f3f3f3f;
  for (i = 0; i < 26; i++) {
    sort(a[i], a[i] + b[i]);
    k = a[i][0] + 1;
    for (j = 1; j < b[i]; j++) {
      k = max(a[i][j] - a[i][j - 1], k);
    }
    k = max(l - a[i][b[i] - 1], k);
    if (b[i] != 0) ans = min(ans, k);
  }
  cout << ans << endl;
}
