#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long MOD = 1e9 + 7;
inline long long add(long long &x, long long y) {
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
inline long long sub(long long x, long long y) {
  x -= y;
  if (x < 0) x += mod;
  return x;
}
inline long long mul(long long x, long long y) { return (x * 1ll * y) % mod; }
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
const long long N = 2e6 + 1;
vector<long long> adj[26];
signed main() {
  string s;
  cin >> s;
  for (long long i = 0; i < s.size(); i++) {
    adj[s[i] - 'a'].push_back(i);
  }
  for (long long i = 0; i < 26; i++) {
    adj[i].push_back(-1);
    adj[i].push_back(s.size());
    sort(adj[i].begin(), adj[i].end());
  }
  long long ans = s.size();
  for (long long i = 0; i < 26; i++) {
    long long cans = 0;
    for (long long j = 0; j < adj[i].size() - 1; j++) {
      cans = max(cans, adj[i][j + 1] - adj[i][j]);
    }
    ans = min(ans, cans);
  }
  cout << ans << endl;
}
