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;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cout << *it << " = " << a << '\n';
  err(++it, args...);
}
const long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  int n = s.size();
  vector<int> arr[26];
  int ans = 1e9;
  for (__typeof(26) i = (0) - (0 > 26); i != (26) - (0 > 26);
       i += 1 - 2 * (0 > 26))
    arr[i].push_back(0);
  for (__typeof(n) i = (0) - (0 > n); i != (n) - (0 > n);
       i += 1 - 2 * (0 > n)) {
    arr[s[i] - 'a'].push_back(i + 1);
  }
  for (__typeof(26) i = (0) - (0 > 26); i != (26) - (0 > 26);
       i += 1 - 2 * (0 > 26))
    arr[i].push_back(n + 1);
  for (__typeof(26) i = (0) - (0 > 26); i != (26) - (0 > 26);
       i += 1 - 2 * (0 > 26)) {
    int t = 0;
    for (__typeof(arr[i].size()) j = (1) - (1 > arr[i].size());
         j != (arr[i].size()) - (1 > arr[i].size());
         j += 1 - 2 * (1 > arr[i].size()))
      t = max(t, arr[i][j] - arr[i][j - 1]);
    ans = min(t, ans);
  }
  cout << ans << '\n';
  return 0;
}
