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;
vector<int> vec[27];
int main() {
  string s;
  cin >> s;
  int ln = s.size() + 1;
  for (int i = 0; i < 26; i++) vec[i].push_back(0);
  for (int i = 0; i < s.size(); i++) {
    vec[s[i] - 'a'].push_back(i + 1);
  }
  for (int i = 0; i < 26; i++) vec[i].push_back(ln);
  int mn = INT_MAX;
  for (int i = 0; i < 26; i++) {
    int mx = 0;
    bool mrk = 0;
    if (vec[i].size() > 1) {
      mrk = 1;
      for (int j = 1; j < vec[i].size(); j++) {
        mx = max(vec[i][j] - vec[i][j - 1], mx);
      }
    }
    if (mrk) mn = min(mn, mx);
  }
  cout << mn << endl;
}
