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;
struct P {
  int x, y;
  bool operator<(const P &a) const { return x > a.x; }
};
vector<int> v[2010];
int a, b, c, o[1010], i, k, d, n, m, e, dy[15] = {0, 0, -1, 1, -1, 1, -1, 1},
                                        dx[15] = {-1, 1, 0, 0, 1, 1, -1, -1};
int l[1555];
long long x, y, z, v1, v2;
P u[100600];
queue<int> q, q1;
map<int, int> p1, p2;
string r, r1;
bool as(P a, P b) { return a.x > b.x; }
long long f(int a) {
  if (a < 2) return 1;
  return f(a - 1) * a;
}
int main() {
  cin >> r;
  for (int t = 'a'; t <= 'z'; t++) {
    v[t].push_back(0);
  }
  for (int t = 0; t < r.size(); t++) v[r[t]].push_back(t + 1);
  for (int t = 'a'; t <= 'z'; t++) v[t].push_back(r.size() + 1);
  k = 987654321;
  for (int t = 'a'; t <= 'z'; t++) {
    i = 0;
    for (int h = 0; h < v[t].size() - 1; h++) i = max(i, v[t][h + 1] - v[t][h]);
    k = min(i, k);
  }
  printf("%d", k);
}
