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>
inline void read(T &x) {
  char c;
  bool nega = 0;
  while ((!isdigit(c = getchar())) && (c != '-'))
    ;
  if (c == '-') {
    nega = 1;
    c = getchar();
  }
  x = c - 48;
  while (isdigit(c = getchar())) x = x * 10 + c - 48;
  if (nega) x = -x;
}
template <typename T>
inline void writep(T x) {
  if (x > 9) writep(x / 10);
  putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  writep(x);
}
template <typename T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
string s;
int last[256];
int k[256];
int main() {
  cin >> s;
  s = '0' + s;
  for (int i = 0; i < s.size(); i++) {
    k[s[i]] = max(k[s[i]], i - last[s[i]]);
    last[s[i]] = i;
  }
  for (int i = 'a'; i <= 'z'; i++) k[i] = max(k[i], ((int)s.size()) - last[i]);
  int ans = s.size() - 1;
  for (int i = 'a'; i <= 'z'; i++)
    if (k[i]) ans = min(ans, k[i]);
  writeln(ans);
}
