#include <bits/stdc++.h>
using namespace std;
long long int cnt[100001][26], l;
long long int ok(long long int len) {
  for (long long int i = 0; i < 26; i++) {
    long long int f = 1;
    for (long long int j = 1; j + len - 1 <= l; j++) {
      if (cnt[j + len - 1][i] - cnt[j - 1][i] == 0) {
        f = 0;
        break;
      }
    }
    if (f) return 1;
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  ;
  cin.tie(0);
  ;
  long long int i, j, x, y, lo, mid, hi;
  string s;
  cin >> s;
  l = s.length();
  s = " " + s;
  for (i = 1; i <= l; i++) {
    for (j = 0; j < 26; j++) cnt[i][j] = cnt[i - 1][j];
    cnt[i][s[i] - 'a']++;
  }
  lo = 0;
  hi = l;
  while (hi - lo > 1) {
    mid = (lo + hi) / 2;
    if (ok(mid))
      hi = mid;
    else
      lo = mid;
  }
  cout << hi;
  return 0;
}
