#include <bits/stdc++.h>
const long long int M = 2000000005;
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t;
  t = 1;
  while (t--) {
    long long int n, i, c, j;
    string s;
    cin >> s;
    n = s.size();
    vector<long long int> v[26];
    for (i = 0; i < 26; i++) {
      v[i].push_back(-1);
    }
    for (i = 0; i < n; i++) {
      c = (long long int)s[i] - 97;
      v[c].push_back(i);
    }
    for (i = 0; i < 26; i++) {
      v[i].push_back(n);
    }
    long long int ans = 1e18, ans1;
    for (i = 0; i < 26; i++) {
      if (v[i].size() == 2) {
        continue;
      }
      ans1 = -1e18;
      for (j = 1; j < v[i].size(); j++) {
        ans1 = max(ans1, v[i][j] - v[i][j - 1]);
      }
      ans = min(ans, ans1);
    }
    cout << ans;
  }
}
