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 str[110000];
int dis_pos[30];
int dis_front[30];
bool visit[30];
int main() {
  while (~scanf("%s", str)) {
    memset(dis_pos, 0, sizeof(dis_pos));
    memset(visit, false, sizeof(visit));
    for (int i = 0; i < 30; i++) {
      dis_front[i] = -1;
    }
    int len = strlen(str);
    for (int i = 0; i < len; i++) {
      dis_pos[str[i] - 'a'] =
          max(dis_pos[str[i] - 'a'], i - dis_front[str[i] - 'a']);
      dis_front[str[i] - 'a'] = i;
      visit[str[i] - 'a'] = true;
    }
    for (int i = 0; i < 26; i++) {
      if (visit[i]) {
        dis_pos[i] = max(dis_pos[i], len - dis_front[i]);
      }
    }
    int result = 110000;
    for (int i = 0; i < 26; i++) {
      if (dis_pos[i] != 0) {
        result = min(result, dis_pos[i]);
      }
    }
    printf("%d\n", result);
  }
  return 0;
}
