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;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const long long int N = 1e5 + 10;
long long int mod = 1e9 + 7;
long long int dx[4] = {0, 0, +1, -1};
long long int dy[4] = {+1, -1, 0, 0};
long long int po(long long int a, long long int b) {
  a %= mod;
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
vector<long long int> h[26];
void solve() {
  string s;
  cin >> s;
  long long int len = (long long int)s.size();
  for (long long int i = 0; i < len; i++) {
    h[s[i] - 'a'].push_back(i);
  }
  for (long long int i = 0; i < 26; i++) {
    h[i].push_back(-1);
    h[i].push_back(len);
    sort((h[i]).begin(), (h[i]).end());
  }
  long long int mx = 1e18;
  for (long long int i = 0; i < 26; i++) {
    long long int l = (long long int)h[i].size();
    long long int maxi = 0;
    for (long long int j = 0; j < l - 1; j++) {
      maxi = max(h[i][j + 1] - h[i][j], maxi);
    }
    mx = min(maxi, mx);
  }
  cout << mx << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  while (t--) solve();
  return 0;
}
