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;
string s;
long long n;
bool check(long long k, char c) {
  map<char, long long> m;
  for (int i = 0; i < k; i++) {
    if (s[i] == c) m[c] = i;
  }
  if (m.empty()) return false;
  for (int j = k; j < n; j++) {
    if (s[j] == c)
      m[c] = j;
    else {
      if (m[c] >= (j - k + 1) && m[c] <= j)
        continue;
      else
        return false;
    }
  }
  return true;
}
signed main() {
  cin >> s;
  set<char> st;
  for (int i = 0; i < s.length(); i++) {
    st.insert(s[i]);
  }
  n = s.length();
  long long res = INT_MAX;
  for (auto c : st) {
    long long lo = 1, hi = n;
    long long ans = 0;
    while (lo <= hi) {
      long long mid = (lo + hi) / 2;
      if (check(mid, c)) {
        ans = mid;
        hi = mid - 1;
      } else
        lo = mid + 1;
    }
    res = min(res, ans);
  }
  cout << res << "\n";
  return 0;
}
