#include <bits/stdc++.h>
using namespace std;
char tochar(int x) { return (char)('a' + x); }
bool check(string a, int k, int n) {
  for (int i = 0; i < 26; i++) {
    int j = 0;
    while (j < n && a[j] != tochar(i)) {
      j++;
    }
    if (j >= k) continue;
    j++;
    int prev = j;
    while (true) {
      while (j < n && a[j] != tochar(i)) {
        j++;
      }
      if (j - prev > k - 1) break;
      if (j == n) {
        return true;
      }
      j++;
      prev = j;
    }
  }
  return false;
}
void solve() {
  string a;
  cin >> a;
  int n = a.size();
  int l = 1, r = n, mid;
  while (l < r) {
    mid = (l + r) / 2;
    if (check(a, mid, n) == true)
      r = mid;
    else
      l = mid + 1;
  }
  cout << l << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
