#include <bits/stdc++.h>
using namespace std;
bool check(vector<long long> s, long long l, long long r, long long m,
           long long k, long long n) {
  long long flag = 0;
  if (s[n - 1] > m) return false;
  for (long long i = n - k - 1, j = n - k; i >= 0 && j < 2 * (n - k);
       --i, j++) {
    if (s[i] + s[j] <= m)
      flag = 1;
    else {
      flag = 0;
      break;
    }
  }
  if (flag == 1)
    return true;
  else
    return false;
}
int main() {
  string s;
  cin >> s;
  int n = s.size(), ans = n;
  for (int i = 0; i < 26; i++) {
    int m = -1, f = -1;
    for (int j = 0; j < n; j++) {
      if ((s[j] - 'a') == i) {
        f = max(f, j - m);
        m = j;
      }
    }
    f = max(f, n - m);
    ans = min(ans, f);
  }
  cout << ans;
}
