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;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
void solve() {
  long long i, j;
  long long c1 = 0, c2 = 0;
  long long ans = (1ll << 60);
  string s;
  cin >> s;
  for (i = 0; i <= 25; i++) {
    c1 = 0;
    c2 = 0;
    for (j = 0; j <= s.length() - 1; j++) {
      if (s[j] - 97 == i) {
        c2 = max(c2, c1 + 1);
        c1 = 0;
      } else
        c1 += 1;
    }
    c2 = max(c2, c1 + 1);
    ans = min(ans, c2);
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    solve();
  }
  return 0;
}
