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;
char s[100010];
map<char, int> q;
map<char, int> m;
map<char, int> w;
int main() {
  scanf("%s", s + 1);
  int l = strlen(s + 1);
  q.clear();
  m.clear();
  w.clear();
  if (l == 1) {
    printf("1\n");
    return 0;
  }
  for (int i = l; i >= 0; i--) w[s[i]] = i;
  for (int i = 1; i <= l; i++) {
    if (m[s[i]] != 0) q[s[i]] = max(q[s[i]], i - m[s[i]]);
    m[s[i]] = i;
  }
  int ans = 100000000;
  for (int i = 1; i <= l; i++) {
    if (q[s[i]] != 0) {
      q[s[i]] = max(q[s[i]], l - m[s[i]] + 1);
      q[s[i]] = max(q[s[i]], w[s[i]]);
      if (q[s[i]] < ans) ans = q[s[i]];
    }
  }
  int p = l / 2 + 1;
  if (ans == 100000000) ans = l / 2 + (l / 2 == 0 ? 0 : 1);
  printf("%d\n", min(p, ans));
}
