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[100005];
vector<int> a[26];
int main() {
  gets(s);
  int len = strlen(s);
  for (int i = 0; i < len; i++) {
    a[s[i] - 'a'].push_back(i + 1);
  }
  int ans = 10000000;
  for (int i = 0; i < 26; i++) {
    if (!a[i].size()) continue;
    int num = 0;
    for (int j = 0; j < a[i].size(); j++) {
      if (j == 0) num = max(num, a[i][j]);
      if (j == a[i].size() - 1) num = max(num, len - a[i][j] + 1);
      if (j != 0) num = max(num, a[i][j] - a[i][j - 1]);
    }
    ans = min(num, ans);
  }
  cout << ans << endl;
  return 0;
}
