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>
#pragma GCC optimize("O3")
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
const ll inf = (1e18);
const ll mod = 1000000007;
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll c, ll d) { return c / GCD(c, d) * d; }
struct __INIT {
  __INIT() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} __init;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
string s;
int n;
int cnt[27][100005] = {};
bool C(int m) {
  V<int> d(26, 0);
  int cn = 0;
  for (int i = 0; i <= n - m; i++) {
    for (int j = 0; j < 26; j++) {
      d[j] += (cnt[j][i + m] - cnt[j][i] > 0);
    }
    cn++;
  }
  return (*max_element((d).begin(), (d).end()) >= cn);
}
int main() {
  cin >> s;
  n = s.size();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 26; j++) {
      if (s[i] - 'a' == j) cnt[j][i + 1]++;
      cnt[j][i + 1] += cnt[j][i];
    }
  }
  int l = 0, r = n;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (C(mid))
      r = mid;
    else
      l = mid;
  }
  cout << r << "\n";
}
