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;
int s[30];
char s1[100005];
int main() {
  cin >> s1;
  int ams;
  int n = strlen(s1);
  for (int i = 0; i < n; i++) s[s1[i] - 'a']++;
  if (n % 2)
    ams = (n + 1) / 2;
  else
    ams = n / 2 + 1;
  for (int i = 0; i < 26; i++) {
    if (s[i] > 1) {
      int ans = 0;
      int pos = 0;
      int sum = 0;
      int v, k;
      for (int j = 0; j < n; j++) {
        if (s1[j] == i + 'a') {
          sum++;
          if (sum == 1)
            v = j;
          else if (sum == s[i])
            k = j;
          ans = max(j - pos, ans);
          pos = j;
        }
      }
      ans = max(ans, max(v + 1, n - k));
      ams = min(ans, ams);
    }
  }
  printf("%d\n", ams);
  return 0;
}
