#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  while (cin >> s) {
    int ans = 1e6;
    for (int i = 'a'; i <= 'z'; i++) {
      int t = 0, k = 0;
      for (int j = 0; j < s.length(); j++) {
        if (s[j] == i)
          t = 0;
        else
          t++;
        k = max(k, t);
      }
      ans = min(ans, k);
    }
    cout << ans + 1 << endl;
  }
  return 0;
}
