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 <typename T>
T sqr(T x) {
  return x * x;
}
const long long shl = 1;
const long long MAXN = 1123456;
vector<long long> tt[1000];
set<long long> ss;
map<string, long long> mp;
string s, s1;
char cc;
long long l, r, c, sc, n, m, i, j, a[MAXN], a1, b1, c1, ans, x, k,
    b[100001][26];
template <typename T>
void vout(T s) {
  cout << s << "\n";
  exit(0);
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cin >> s;
  n = s.size();
  for (i = 1; i <= n; i++) {
    for (j = 0; j < 26; j++) b[i][j] = b[i - 1][j];
    long long x = s[i - 1] - 'a';
    b[i][x]++;
  }
  l = 1;
  r = n;
  ans = n;
  while (l < r) {
    long long c = (l + r) / 2;
    long long fl1 = 0;
    for (i = 0; i < 26; i++) {
      long long fl = 0;
      for (j = 1; j <= n - c + 1; j++)
        if (b[j + c - 1][i] - b[j - 1][i] == 0) {
          fl = 1;
          break;
        }
      if (fl == 0) fl1 = 1;
    }
    if (fl1 == 1) {
      ans = min(ans, c);
      r = c;
    } else
      l = c + 1;
  }
  cout << ans << "\n";
  return 0;
}
