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);
  cout.tie(NULL);
  string s;
  cin >> s;
  map<char, vector<long long>> mpp;
  long long n = s.size();
  for (int i = 0; i < 26; i++) mpp[(char)(97 + i)].push_back(0);
  for (int i = 0; i < n; i++) {
    mpp[s[i]].push_back(i + 1);
  }
  for (int i = 0; i < 26; i++) mpp[(char)(97 + i)].push_back(n + 1);
  long long ans = INT_MIN;
  long long res = INT_MAX;
  for (auto itr = mpp.begin(); itr != mpp.end(); itr++) {
    long long sss = itr->second.size();
    ans = INT_MIN;
    for (int i = 1; i < sss; i++) {
      ans = max(ans, itr->second[i] - itr->second[i - 1]);
    }
    res = min(ans, res);
  }
  cout << res;
}
