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;
const int INF = 1e9 + 7;
string s;
bool letter_is_dominant(char c, int len) {
  int cnt = 0;
  for (int i = 0; i < len; ++i) {
    if (s[i] == c) ++cnt;
  }
  if (cnt == 0) return 0;
  for (int i = len; i < s.size(); ++i) {
    if (s[i] == c) ++cnt;
    if (s[i - len] == c) --cnt;
    if (cnt == 0) return 0;
  }
  return 1;
}
bool is_dominant(int len) {
  for (char i = 'a'; i <= 'z'; ++i) {
    if (letter_is_dominant(i, len)) return 1;
  }
  return 0;
}
int main() {
  cin >> s;
  int l = 1, r = s.size();
  while (l + 1 < r) {
    int b = l + (r - l) / 2;
    if (is_dominant(b))
      r = b;
    else
      l = b + 1;
  }
  if (is_dominant(l))
    cout << l;
  else
    cout << l + 1;
  return 0;
}
