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;
vector<long long> v;
long long check[100], last[34];
int main() {
  long long i;
  string s;
  cin >> s;
  for (i = 0; i < 30; i++) last[i] = -1;
  for (i = 0; i < s.length(); i++) {
    check[s[i] - 'a'] = max(check[s[i] - 'a'], i - last[s[i] - 'a']);
    last[s[i] - 'a'] = i;
  }
  for (i = 0; i < 26; i++)
    check[i] = max((long long)s.length() - last[i], check[i]);
  cout << *min_element(check, check + 26);
}
