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 int MOD = 1000000009;
const long long INF = 1000000007;
const int sz = 40100;
const double EPS = 1e-9;
int n, y, x;
string s;
map<char, int> ms;
bool cr(char c, int k) {
  ms.clear();
  for (int i = 0; i < k; ++i) {
    ++ms[s[i]];
  }
  if (ms[c] == 0) return 0;
  for (int i = k; i < n; ++i) {
    --ms[s[i - k]];
    ++ms[s[i]];
    if (ms[c] == 0) return 0;
  }
  return 1;
}
bool correct(int k) {
  for (char c = 'a'; c <= 'z'; ++c) {
    ms[c] = 0;
  }
  for (char c = 'a'; c <= 'z'; ++c) {
    if (cr(c, k)) return 1;
  }
  return 0;
}
int main() {
  cin >> s;
  n = s.size();
  int l = 1, r = n;
  while (l + 1 < r) {
    int b = (r + l) / 2;
    if (correct(b))
      r = b;
    else
      l = b;
  }
  if (correct(l))
    cout << l;
  else
    cout << r;
  return 0;
}
