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 long long inf = 1e9;
const long long inf64 = 1e18;
const long long mod = inf + 7;
const long long N = 1e3 + 10;
void solve() {
  string s;
  cin >> s;
  long long n = (long long)s.size();
  set<long long> pos[26];
  for (long long i = 0; i < n; i++) pos[s[i] - 'a'].insert(i);
  long long ans = inf;
  for (long long i = 0; i < 26; i++) pos[i].insert(-1), pos[i].insert(n);
  for (long long i = 0; i < 26; i++) {
    long long ind = -1, cur = 0;
    auto it = pos[i].lower_bound(ind);
    while (it != pos[i].end()) {
      cur = max(cur, *it - ind);
      ind = *it;
      it = pos[i].lower_bound(*it + 1);
    }
    ans = min(ans, cur);
  }
  cout << ans << "\n";
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long tc = 1;
  while (tc--) solve();
}
