#include <bits/stdc++.h>
char s[100001], t;
int p[128], c[128], tc;
int main() {
  int i, m, k;
  scanf("%s", s);
  for (i = 97; i < 123; i++) {
    p[i] = -1, c[i] = 0;
  }
  for (i = 0; s[i]; i++) {
    t = s[i];
    tc = i - p[t];
    if (tc > c[t]) c[t] = tc;
    p[t] = i;
  }
  for (k = m = i, i = 97; i < 123; i++) {
    tc = k - p[i];
    if (tc > c[i]) c[i] = tc;
    if (c[i] < m) m = c[i];
  }
  printf("%d\n", m);
  return 0;
}
