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 str;
long n;
bool chck(long k) {
  map<char, long> m;
  for (long i = 0; i < k; i++) m[str[i]]++;
  for (long i = k, j = 0; i < n; i++, j++) {
    if (m.find(str[i]) != m.end()) m[str[i]]++;
    if (m.find(str[j]) != m.end()) m[str[j]]--;
    if (!m[str[j]]) m.erase(str[j]);
  }
  if (m.size()) return true;
  return false;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> str;
  n = str.size();
  long start = 1, end = n;
  while (start < end) {
    long mid = (start + end) / 2;
    if (chck(mid))
      end = mid;
    else
      start = mid + 1;
  }
  cout << start;
  return 0;
}
