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, s1;
int n, f[26], mx, ans, ans1 = 1e9;
char cmx;
vector<int> v[26];
int main() {
  cin >> s;
  s = " " + s + " ";
  n = s.size();
  for (int i = 0; i < 26; i++) {
    v[i].push_back(0);
  }
  for (int i = 1; i < n - 1; i++) {
    f[s[i] - 'a']++;
    v[s[i] - 'a'].push_back(i);
  }
  for (int i = 0; i < 26; i++) {
    v[i].push_back(n - 1);
  }
  for (int i = 0; i < 26; i++) {
    if (mx < f[i]) {
      mx = f[i];
      cmx = (char)(i + 'a');
    }
  }
  if (mx == 1) return cout << (n - 2) / 2 + 1, 0;
  for (int j = 0; j < 26; j++) {
    if (f[j] > 0) {
      ans = 0;
      for (int i = 1; i < v[j].size(); i++) {
        ans = max(ans, v[j][i] - v[j][i - 1]);
      }
      ans1 = min(ans1, ans);
    }
  }
  cout << ans1;
  return 0;
}
