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() {
  iostream::sync_with_stdio(false);
  ;
  string s;
  cin >> s;
  int maior = 1000000;
  int max_l = 0, cont = 0;
  for (int i = 0; i < s.length(); i++) {
    max_l = 0;
    cont = 0;
    if (s[i] != 'A') {
      int ultima = 0;
      max_l = i;
      for (int j = i + 1; j < s.length(); j++) {
        if (s[i] == s[j]) {
          s[j] = 'A';
          cont = 0;
          ultima = j;
        } else {
          cont++;
        }
        max_l = max(cont, max_l);
      }
      int dif = s.length() - ultima;
      maior = min(maior, max_l);
    }
  }
  cout << maior + 1 << endl;
  return 0;
}
