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;
int len;
int ans;
int main() {
  cin >> s;
  len = s.size();
  vector<int> v;
  set<char> st;
  for (int i = 0; i < len; i++) {
    st.insert(s[i]);
  }
  int ans = 0;
  for (int i = 0; i < len; i++) {
    if (st.count(s[i])) {
      int a = i;
      ans = i;
      for (int j = i + 1; j < len; j++) {
        if (s[j] == s[i]) {
          ans = max(ans, j - a - 1);
          a = j;
        }
      }
      ans = max(ans, len - 1 - a);
      v.push_back(ans);
      ans = 0;
    }
    st.erase(s[i]);
  }
  ans = *min_element(v.begin(), v.end());
  cout << ans + 1;
  return 0;
}
