#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  long long int n = s.size();
  long long int i, j;
  long long int fre[26] = {0};
  long long int ans = (n / 2) + 1;
  for (i = 0; i < n; i++) fre[s[i] - 'a']++;
  long long int si = 26;
  for (i = 0; i < si; i++) {
    if (fre[i] >= 2) {
      long long int start = 0, tem = 0;
      for (j = 0; j < n; j++) {
        if ((s[j] - 'a') == i) {
          start = j;
          break;
        }
      }
      tem = max(tem, start + 1);
      for (j = start + 1; j < n; j++) {
        if ((s[j] - 'a') == i) {
          tem = max(j - start, tem);
          start = j;
        }
      }
      tem = max(n - start, tem);
      ans = min(ans, tem);
    }
  }
  cout << ans << "\n";
  return 0;
}
