#include <bits/stdc++.h>
using namespace std;
const int AL = 26;
vector<int> op[AL];
int n;
int main() {
  string a;
  cin >> a;
  n = a.size();
  for (int i = 0; i < n; i++) {
    op[a[i] - 97].push_back(i);
  }
  int ans = 2e9;
  int cur;
  int k;
  for (int i = 0; i < 26; i++) {
    if (op[i].empty()) continue;
    cur = max(op[i][0], n - (op[i][op[i].size() - 1] + 1));
    for (int j = 1; j < op[i].size(); j++) {
      cur = max(cur, (op[i][j] - op[i][j - 1]) / 2);
    }
    ans = min(ans, cur);
  }
  cout << ans;
  return 0;
}
