#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 1;
const int MAXM = 1002;
const int inf = 1e9 + 7;
const int siz = 60;
const string ABC = "0123456789";
ifstream in("input.txt");
ofstream out("output.txt");
int main() {
  string s;
  cin >> s;
  int ans = s.size();
  for (int j = 0; j < 26; j++) {
    int pre = -1;
    int maxi = 0;
    for (int i = 0; i < s.size(); i++) {
      if ((s[i] - 'a') == j) {
        maxi = max(maxi, i - pre);
        pre = i;
      }
    }
    maxi = max(maxi, (int)s.size() - pre);
    ans = min(ans, maxi);
  }
  cout << ans;
  return 0;
}
