#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int pos[26], distmax[26];
  for (int i = 0; i < 26; i++) pos[i] = 0, distmax[i] = 0;
  for (int i = 0; i < s.length(); i++) {
    int j = i + 1;
    int charin = s[i] - 'a';
    distmax[charin] = max(distmax[charin], j - pos[charin]);
    pos[charin] = j;
  }
  int ans = INT_MAX;
  for (int i = 0; i < 26; i++) {
    int p = s.length();
    p = p + 1 - pos[i];
    distmax[i] = max(distmax[i], p);
  }
  for (int i = 0; i < 26; i++) ans = min(ans, distmax[i]);
  cout << ans;
}
