#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n, l, r, ans;
  n = s.size();
  ans = n + 1;
  for (char c = 'a'; c <= 'z'; c++) {
    l = 0, r = n + 1;
    int mx = -1;
    for (int i = 0; i < n; i++) {
      if (s[i] == c) {
        r = i + 1;
        mx = max(r - l, mx);
        l = r;
      }
    }
    r = n + 1;
    mx = max(r - l, mx);
    ans = min(mx, ans);
  }
  cout << ans;
}
