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;
  long long n = s.size();
  vector<long long> ad[26];
  long long ans = n;
  for (long long i = (long long)0; i < (long long)n; i++) {
    ad[s[i] - 'a'].push_back(i);
  }
  for (long long i = (long long)0; i < (long long)26; i++) {
    ad[i].push_back(-1);
    ad[i].push_back(n);
    sort(ad[i].begin(), ad[i].end());
  }
  for (long long i = (long long)0; i < (long long)26; i++) {
    long long kk = 0;
    for (long long j = (long long)0; j < (long long)ad[i].size() - 1; j++) {
      kk = max(kk, ad[i][j + 1] - ad[i][j]);
    }
    ans = min(ans, kk);
  }
  cout << ans;
}
