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;
const long long INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
long long MAXN = 10e9;
int main() {
  string s;
  cin >> s;
  map<char, vector<int> > mp;
  for (int ch = 'a'; ch <= 'z'; ch++) mp[ch].push_back(0);
  for (long long i = 0; i < s.size(); i++) mp[s[i]].push_back(i + 1);
  int n = s.size();
  for (int ch = 'a'; ch <= 'z'; ch++) mp[ch].push_back(n + 1);
  int minians = inf;
  for (int ch = 'a'; ch <= 'z'; ch++) {
    int sz = mp[ch].size();
    int mini = 0;
    for (long long i = 1; i < sz; i++)
      mini = max(mini, mp[ch][i] - mp[ch][i - 1]);
    minians = min(minians, mini);
  }
  cout << minians;
}
