#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class t>
using V = vector<t>;
string s;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> s;
  for (char& c : s) c -= 'a';
  int res = 1e9;
  for (int i = 0; i < 26; ++i) {
    V<int> tmp;
    int curr = 0;
    for (char c : s)
      if (c == i) {
        tmp.emplace_back(curr);
        curr = 0;
      } else
        ++curr;
    tmp.emplace_back(curr);
    int tmpres = 0;
    for (int i = 1; i < (int)tmp.size() - 1; ++i)
      tmpres = max(tmpres, (tmp[i] / 2) + (tmp[i] % 2));
    tmpres = max(tmpres, tmp[0]);
    tmpres = max(tmpres, tmp[(int)tmp.size() - 1]);
    res = min(res, tmpres);
  }
  cout << res << '\n';
}
