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 MOD = 1e9 + 7;
const long long SIZE = 100000;
const int INF = 0x3f3f3f3f;
const long long ll_INF = 0x3f3f3f3f3f3f3f3f;
const long double PI = acos(-1);
const long long MAXN = numeric_limits<long long>::max();
const long long MAX = 2000000;
void solve() {
  string s;
  cin >> s;
  vector<long long> b(26, 0), a(26, -1);
  for (long long i = 0; i < ((int)(s).size()); i++) {
    if (a[s[i] - 97] == -1) {
      a[s[i] - 97] = i + 1;
      b[s[i] - 97] = i + 1;
    } else if (b[s[i] - 97] < i + 1 - a[s[i] - 97]) {
      b[s[i] - 97] = i + 1 - a[s[i] - 97];
    }
    a[s[i] - 97] = i + 1;
  }
  for (long long i = 0; i < 26; i++) {
    if (a[i] != -1) b[i] = max(b[i], ((int)(s).size()) - a[i] + 1);
  }
  for (long long i = 0; i < ((int)(b).size()); i++) {
    if (b[i] == 0) {
      b.erase(b.begin() + i);
      i--;
    }
  }
  if (((int)(b).size()) == 0) {
    cout << ((int)(s).size()) / 2 + 1;
  } else {
    sort((b).begin(), (b).end());
    cout << b.front();
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
