#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 5;
const long long N = 205;
string s;
long long n;
bool check(long long mid) {
  long long i, j;
  for (i = 0; i < 26; i++) {
    char ch = 'a' + i;
    long long cnt = 0, temp = 0;
    for (j = 0; j < n; j++) {
      if (s[j] == ch) cnt++;
      if (j - temp + 1 > mid) {
        if (s[temp] == ch) cnt--;
        temp++;
      }
      if (j - temp + 1 == mid && cnt == 0) {
        break;
      }
    }
    if (j == n) return true;
  }
  return false;
}
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() {
  cin >> s;
  n = s.size();
  if (n == 1) {
    cout << 1 << "\n";
    return;
  }
  bool ok = true;
  for (long long i = 1; i < n; i++) {
    if (s[i] != s[i - 1]) {
      ok = false;
      break;
    }
  }
  if (ok) {
    cout << 1 << "\n";
    return;
  }
  long long l = 1, r = n, ans = 0;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (check(mid)) {
      ans = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  cout << ans << "\n";
}
