#include <bits/stdc++.h>
using namespace std;
int max1(int a, int b) { return a > b ? a : b; }
int min1(int a, int b) { return a < b ? a : b; }
int main() {
  string s;
  while (cin >> s) {
    int ans = 100000;
    map<char, int> m;
    map<char, int> m1;
    map<char, int> m2;
    for (int i = 0; i < s.length(); i++) {
      if (m.count(s[i])) {
        m[s[i]] = max1(i + 1 - m2[s[i]], m[s[i]]);
        m2[s[i]] = i + 1;
      } else {
        m[s[i]] = i + 1;
        m2[s[i]] = i + 1;
      }
    }
    for (int i = s.length(); i >= 0; i--) {
      if (!m1.count(s[i])) {
        m1[s[i]] = s.length() - i;
      }
    }
    for (map<char, int>::iterator it = m.begin(); it != m.end(); it++) {
      it->second = max1(it->second, m1[it->first]);
      ans = min1(ans, it->second);
    }
    cout << ans << endl;
  }
  return 0;
}
