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 MAX_N = 1e5 + 10;
const long long mod = 1e9 + 7;
const long long INF = 1e9;
inline long long bpow(long long t, long long n) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) ans = (ans * t) % mod;
    t = (t * t) % mod, n >>= 1;
  }
  return ans;
}
vector<int> vec[1200];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(0);
  string s;
  cin >> s;
  int n = s.length();
  for (int i = 0; i < n; i++) vec[s[i]].push_back(i);
  int ans = n / 2 + 1;
  for (int i = 'a'; i <= 'z'; i++) {
    int siz = vec[i].size();
    if (siz == 0) continue;
    if (siz == 1) {
      continue;
    }
    int curr = max(vec[i][0] + 1, abs(n - vec[i][siz - 1]));
    for (int j = 1; j < siz; j++)
      curr = max(curr, abs(vec[i][j] - vec[i][j - 1]));
    ans = min(ans, curr);
  }
  cout << ans;
}
