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 long long fx[] = {0, 1, 0, -1};
const long long fy[] = {1, 0, -1, 0};
const long long mod = 1e9 + 7;
void oka() {
  long long i, j, k, n;
  string s;
  long long mn = 1e10, mx = 0, cnt = 0;
  long long cur[27], las[27];
  cin >> s;
  for (char a = 'a'; a <= 'z'; a++) {
    for (i = 0; i <= s.size(); i++) {
      cnt++;
      mx = max(mx, cnt);
      if (a == s[i]) cnt = 0;
    }
    mn = min(mx, mn);
    cnt = 0, mx = 0;
  }
  cout << mn << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  t = 1;
  while (t--) {
    oka();
  }
}
