#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
const long long int INF = 1e18;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;
int cas = 1;
char s[maxn];
int len;
int cal(char ch) {
  int ans = 0;
  int pre = 0;
  for (int i = 1; i <= len; i++) {
    if (s[i] == ch) {
      ans = max(ans, i - pre);
      pre = i;
    }
  }
  ans = max(ans, len - pre + 1);
  return ans;
}
void solve() {
  while (~scanf("%s", s + 1)) {
    len = strlen(s + 1);
    int res = inf;
    for (int i = 0; i < 26; i++) {
      res = min(res, cal(i + 'a'));
    }
    cout << res << endl;
  }
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
