#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 5;
const long long N = 205;
void solve();
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cout << fixed << setprecision(10);
  long long _ = 1;
  while (_--) solve();
  return 0;
}
void solve() {
  string s;
  cin >> s;
  long long n = s.size();
  long long ans = LLONG_MAX;
  for (long long loop = 0; loop < 26; loop++) {
    char ch = 'a' + loop;
    long long cnt = 0, temp = 0;
    for (long long i = 0; i < n; i++) {
      cnt++;
      if (ch == s[i]) {
        temp = max(temp, cnt);
        cnt = 0;
      }
    }
    if (cnt) cnt++;
    temp = max(temp, cnt);
    ans = min(temp, ans);
  }
  cout << ans << "\n";
}
