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;
bool funct(string s, long long k) {
  bool check = true;
  for (char c = 'a'; c <= 'z'; c++) {
    check = true;
    long long occurence = -1;
    for (long long i = 0; i < k; i++) {
      if (s[i] == c) {
        occurence = i;
      }
    }
    if (occurence == -1) continue;
    for (long long i = k; i < s.size(); i++) {
      if (s[i] == c) occurence = i;
      if (occurence <= i - k) {
        check = false;
        break;
      }
    }
    if (check) return true;
  }
  return false;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  long long lo = 1, hi = s.size();
  long long res;
  while (lo <= hi) {
    long long mid = (hi + lo) / 2;
    if (funct(s, mid))
      res = mid, hi = mid - 1;
    else
      lo = mid + 1;
  }
  cout << res;
}
