#include <bits/stdc++.h>
using namespace std;
string s;
int arr[26][2];
int main() {
  cin >> s;
  for (int i = 0; i < 26; i++) {
    arr[i][0] = -1;
    arr[i][1] = -1;
  }
  int len = s.size();
  for (int i = 0; i < len; i++) {
    if (arr[s[i] - 'a'][1] == -1) {
      arr[s[i] - 'a'][1] = i;
      arr[s[i] - 'a'][0] = i + 1;
    } else {
      int gap = i - arr[s[i] - 'a'][1];
      arr[s[i] - 'a'][0] = max(arr[s[i] - 'a'][0], gap);
      arr[s[i] - 'a'][1] = i;
    }
  }
  int ans = (len / 2) + 1;
  for (int i = 0; i < 26; i++) {
    if (arr[i][0] != -1) {
      arr[i][0] = max(arr[i][0], len - arr[i][1]);
      ans = min(ans, arr[i][0]);
    }
  }
  cout << ans;
  return 0;
}
