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;
int main() {
  long long int n, m, i, j, k, l, r, x, y, z, t;
  string s;
  cin >> s;
  l = s.size();
  vector<long long int> u, v[27];
  for (i = 0; i < 27; i++) v[i].push_back(0LL);
  for (i = 0; i < s.size(); i++) {
    k = s[i] - 'a';
    v[k].push_back(i + 1);
  }
  for (i = 0; i < 27; i++) v[i].push_back(l + 1);
  x = s.size();
  for (i = 0; i < 26; i++) {
    k = 0;
    if (v[i].size() == 0) continue;
    if (v[i].size() == 1) {
      continue;
    }
    for (j = 0; j < v[i].size() - 1; j++) {
      k = max(k, v[i][j + 1] - v[i][j]);
    }
    x = min(x, k);
  }
  cout << x << endl;
}
