#include <bits/stdc++.h>
using namespace std;

int main() {
  string s; cin >> s;
  int n = s.length();
  int ans = n-1;
  for (char c = 'a'; c <= 'z'; c++) {
    	int res = 0;
  		for (int i = 0; i < n; i++) {
        	int j = i;
          	while (j<n && s[j] != c) j++;
          	res = max(res,j-i);
        }
    	ans = min(ans,res);
  }
  cout << ans << endl;
  return 0; 
}