#include <bits/stdc++.h>
using namespace std;
int a[26];
int x[26];
int main() {
  string s;
  cin >> s;
  int len = s.size();
  memset(x, -1, sizeof(x));
  memset(a, -1, sizeof(a));
  for (int i = 0; i < len; i++) {
    int tmp = s[i] - 'a';
    if (a[tmp] == -1) {
      x[tmp] = i + 1;
      a[tmp] = i;
      continue;
    } else {
      x[tmp] = max(x[tmp], i - a[tmp]);
      a[tmp] = i;
    }
  }
  for (int i = 0; i < 26; i++) {
    x[i] = max(len - a[i], x[i]);
  }
  int res = 0x3f3f3f;
  for (int i = 0; i < 26; i++) {
    if (a[i] != -1) {
      if (x[i] != -1) res = min(res, x[i]);
    }
  }
  cout << res << endl;
  return 0;
}
