#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[1000000];
  cin >> s;
  int l = strlen(s);
  int a[26][2];
  char x = 0;
  int diff = 0;
  for (int i = 0; i < 26; i++) {
    a[i][0] = 0;
    a[i][1] = 0;
  }
  for (int i = 0; s[i] != '\0'; i++) {
    x = (int)s[i];
    x = x - 97;
    diff = i - a[x][1];
    if (a[x][0] == 0) {
      diff++;
    }
    if (diff > a[x][0]) {
      a[x][0] = diff;
    }
    a[x][1] = i;
  }
  for (int i = 0; i < 26; i++) {
    diff = l - a[i][1];
    if (diff > a[i][0]) {
      a[i][0] = diff;
    }
  }
  int min = 1000000;
  for (int i = 0; i < 26; i++) {
    if ((a[i][0] < min) && (a[i][0] != 0)) {
      min = a[i][0];
    }
  }
  cout << min << endl;
  return 0;
}
