#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
char s[N];
int n, a[26], k[26];
int main() {
  gets(s + 1);
  n = strlen(s + 1);
  memset(k, 0, sizeof k);
  memset(a, 0, sizeof a);
  for (int i = 1; i <= n; ++i) {
    k[s[i] - 'a'] = max(k[s[i] - 'a'], i - a[s[i] - 'a']);
    a[s[i] - 'a'] = i;
  }
  for (int i = 0; i < 26; ++i) k[i] = max(k[i], n + 1 - a[i]);
  int ans = n;
  for (int i = 0; i < 26; ++i) ans = min(k[i], ans);
  printf("%d\n", ans);
  return 0;
}
