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>
char a[100010];
int main() {
  int ascii[26] = {0};
  int size = 0;
  scanf("%s", &a);
  for (int i = 1; i <= 100000; i++) {
    if (a[i] == '\0') {
      size = i;
      break;
    }
  }
  for (int i = 0; i < 26; i++) {
    int fir = 0;
    int sec = 0;
    int res = 0;
    for (int j = 0; j <= size; j++) {
      if (j == size) {
        if (a[j] != i + 97) {
          if (j - fir > res) {
            res = j - fir;
          }
        }
        break;
      }
      if (a[j] == i + 97) {
        sec = j;
        if (fir == 0) {
          int delta;
          if (a[fir] == i + 97) {
            delta = sec - fir;
          } else {
            delta = sec - fir + 1;
          }
          res = delta;
        } else if (a[fir] == i + 97) {
          int delta = sec - fir;
          if (delta > res) {
            res = delta;
          }
        }
        fir = j;
      }
    }
    ascii[i] = res;
  }
  int result = size / 2 + 1;
  for (int i = 0; i < 26; i++) {
    if (ascii[i] < result && ascii[i]) {
      result = ascii[i];
    }
  }
  printf("%d", result);
  return 0;
}
