#include <bits/stdc++.h>
using namespace std;
char s[100005];
int n;
bool check(int p) {
  for (char c = 'a'; c <= 'z'; ++c) {
    bool f = true;
    int x = 0;
    for (int i = 0; i < n; ++i) {
      if (s[i] != c) {
        x++;
      } else {
        x = 0;
      }
      if (x >= p) {
        f = false;
        break;
      }
    }
    if (f) {
      return true;
    }
  }
  return false;
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  int l = 0, r = n + 1, ans = r;
  while (l <= r) {
    int m = l + r >> 1;
    if (check(m)) {
      ans = m;
      r = m - 1;
    } else {
      l = m + 1;
    }
  }
  printf("%d\n", ans);
  fprintf(stderr, "\n\nSystem Time : %d ms", clock()), fflush(stderr);
  return 0;
}
