#include <bits/stdc++.h>
using namespace std;
vector<int> v[26];
int A[26], m;
void solve() {
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++) v[s[i] - 'a'].push_back(i);
  for (int i = 0; i < 26; i++) {
    if (s.find(i + 'a') != string::npos) {
      m = v[i][0] + 1;
      for (int j = 1; j < (int)v[i].size(); j++)
        m = max(m, v[i][j] - v[i][j - 1]);
      m = max(m, (int)s.length() - v[i][(int)v[i].size() - 1]);
      A[i] = m;
    }
  }
  m = INT_MAX;
  for (int i = 0; i < 26; i++) {
    if (A[i] != 0) m = min(m, A[i]);
  }
  cout << m << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
