#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> k(26, -1e9);
  string s;
  cin >> s;
  int n = (int)s.length();
  for (char c = 'a'; c <= 'z'; ++c) {
    int prev = -1;
    for (int i = 0; i < n; ++i) {
      if (s[i] == c) {
        k[c - 'a'] = max(i - prev, k[c - 'a']);
        prev = i;
      }
    }
    k[c - 'a'] = max(n - prev, k[c - 'a']);
  }
  int ans = n;
  for (int i = 0; i < 26; ++i) {
    if (k[i] != -1e9) {
      ans = min(ans, k[i]);
    }
  }
  cout << ans;
}
