#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, MOD = 1e9 + 7;
int main() {
  vector<int> a(27, -1), b(27, -1), c(27, -1);
  string str;
  cin >> str;
  for (int i = 0; i < (int)str.size(); i++) {
    if (a[str[i] - 'a'] == -1) {
      a[str[i] - 'a'] = i;
      c[str[i] - 'a'] = i;
    } else {
      b[str[i] - 'a'] = max(i - a[str[i] - 'a'], b[str[i] - 'a']);
      a[str[i] - 'a'] = i;
    }
  }
  int x = (int)str.size() - 1;
  int ans = (int)str.size() / 2 + 1;
  for (int i = 0; i < 27; i++) {
    if (b[i] != -1) {
      b[i] = max({b[i], x - a[i] + 1, c[i] + 1});
      ans = min(b[i], ans);
    }
  }
  cout << ans << endl;
  return 0;
}
