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 main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  long long int len = s.length();
  long a[26][len + 1];
  for (int i = 0; i < 26; i++) {
    for (long long int j = 0; j <= len; j++) {
      a[i][j] = 0;
    }
  }
  for (long long int i = 0; i < len; i++) {
    a[s[i] - 'a'][i] = 1;
  }
  long long int maxm[26] = {0};
  for (long long int i = 0; i < 26; i++) {
    long long int k = -1;
    for (long long int j = 0; j < len; j++) {
      if (a[i][j] == 1) {
        maxm[i] = max(maxm[i], j - k);
        k = j;
      }
    }
    maxm[i] = max(maxm[i], len - k);
  }
  long long int minm = 1e9;
  for (int i = 0; i < 26; i++) {
    if (maxm[i] == 0) continue;
    if (maxm[i] < minm) {
      minm = maxm[i];
    }
  }
  cout << minm;
  return 0;
}
