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 maxchar = 26;
const int maxx = 100000 + 8;
int last[maxchar];
int maxlen[maxchar];
int solve(string s) {
  int len = (int)s.length();
  for (int i = 0; i < len; i++) {
    int c = s[i] - 'a';
    maxlen[c] = max(maxlen[c], i - last[c]);
    last[c] = i;
  }
  int ans = maxx;
  for (int i = 0; i < maxchar; i++) {
    maxlen[i] = max(maxlen[i], len - last[i]);
    ans = min(ans, maxlen[i]);
  }
  return ans;
}
int main(int argc, const char* argv[]) {
  memset(last, -1, sizeof(last));
  memset(maxlen, -1, sizeof(maxlen));
  string s;
  cin >> s;
  int k = solve(s);
  cout << k << endl;
  return 0;
}
