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 int N = 1e2 + 9;
string s = ".";
long long cnt(char c) {
  vector<long long> pos(1);
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == c) pos.push_back(i);
  }
  pos.push_back(s.size());
  long long mx = 0;
  for (int i = 1; i < pos.size(); i++) {
    mx = max(mx, pos[i] - pos[i - 1]);
  }
  return mx;
}
int main() {
  ios_base::sync_with_stdio(false);
  string x;
  cin >> x;
  s += x;
  long long mn = 2e18;
  for (int i = 0; i < 26; i++) {
    mn = min(mn, cnt('a' + i));
  }
  cout << mn;
}
