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;
long long modpow(long long a, long long n, long long temp) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = (res * a) % temp;
    a = (a * a) % temp;
    n >>= 1;
  }
  return res % temp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.precision(10);
  cout << fixed;
  string s;
  cin >> s;
  int id[27] = {0}, k[27] = {0};
  for (int i = 0; i < s.size(); i++) {
    k[s[i] - 'a'] = max(i + 1 - id[s[i] - 'a'], k[s[i] - 'a']);
    id[s[i] - 'a'] = i + 1;
  }
  for (int i = 0; i < 26; i++)
    if (id[i] != 0) k[i] = max(k[i], (int)s.size() - id[i] + 1);
  int res = INT_MAX;
  for (int i = 0; i < 26; i++) {
    if (k[i] != 0) res = min(res, k[i]);
  }
  cout << res << "\n";
  if (0) cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  return 0;
}
