#include<iostream>
using namespace std;

int main(){
  string s;
  cin >> s;

  int ans = 1000;
  for(char target = 'a'; target <= 'z'; target++){
    int prev = -1, max_dist_i = 0;
    for(int i = 0; i < s.size(); i++){
      if(s[i] == target){
        max_dist_i = max(max_dist_i, i - prev - 1);
        prev = i;
      }
    }
    max_dist_i = max(max_dist_i, static_cast<int>(s.size()) - prev - 1);
    ans = min(ans, max_dist_i);
  }
  cout << ans << endl;
}
