#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int t = 1;
  while (t--) {
    string s;
    cin >> s;
    long long n = s.length();
    vector<long long> v[26];
    for (int i = 0; i < 26; i++) {
      v[i].push_back(0);
    }
    for (int i = 0; i < n; i++) {
      v[s[i] - 'a'].push_back(i + 1);
    }
    for (int i = 0; i < 26; i++) {
      v[i].push_back(n + 1);
    }
    long long ans = INT_MAX;
    for (int i = 0; i < 26; i++) {
      long long m = v[i].size();
      long long res = 0;
      for (int j = 1; j < m; j++) {
        res = max(res, v[i][j] - v[i][j - 1]);
      }
      ans = min(ans, res);
    }
    cout << ans << "\n";
  }
  return 0;
}
