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 main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  long long int n = s.size();
  vector<int> lind(26, -1), mx(26, -1);
  for (int i = 0; i < s.size(); ++i) {
    if (i - lind[s[i] - 'a'] > mx[s[i] - 'a']) {
      mx[s[i] - 'a'] = i - lind[s[i] - 'a'];
    }
    lind[s[i] - 'a'] = i;
  }
  for (int i = 0; i < 26; ++i) {
    if (n - lind[i] > mx[i]) {
      mx[i] = n - lind[i];
    }
  }
  long long int mn = 1000000;
  for (int i = 0; i < 26; ++i) {
    if (mx[i] != -1 && mx[i] < mn) mn = mx[i];
  }
  cout << mn << endl;
  return 0;
}
