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;
void solve() {
  string s;
  cin >> s;
  map<char, long long> m;
  long long l = s.length();
  long long gmin = s.length();
  for (long long i = 0; i < gmin; i++) {
    m[s[i]]++;
  }
  for (char c = 'a'; c <= 'z'; c++) {
    if (m[c] == 0) {
      continue;
    }
    long long count = 0, ed = l, mid = -1, li = -1;
    for (long long i = 0; i < l; i++) {
      if (s[i] == c) {
        count++;
        long long t = i - li;
        li = i;
        mid = max(mid, t);
        if (count == m[c]) {
          ed = l - i;
          mid = max(mid, ed);
        }
      }
    }
    gmin = min(gmin, mid);
  }
  cout << gmin << endl;
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) {
    solve();
  }
}
