#include <bits/stdc++.h>
using namespace std;
int a[30];
int b[30];
int c[30];
int main() {
  char s[100005];
  int i, t;
  memset(b, 0, sizeof(b));
  for (i = 0; i < 26; i++) a[i] = -1;
  memset(c, 0, sizeof(c));
  scanf("%s", s);
  for (i = 0; s[i]; i++) {
    t = s[i] - 'a';
    b[t] = max(b[t], i - a[t]);
    a[t] = i;
    c[t]++;
  }
  for (i = 0; i < 26; i++) {
    int temp = strlen(s) - a[i];
    if (c[i]) b[i] = max(b[i], temp);
  }
  int minn = 1008611;
  for (i = 0; i < 26; i++) {
    if (c[i] != 0) minn = min(minn, b[i]);
  }
  printf("%d\n", minn);
  return 0;
}
