#define _USE_MATH_DEFINES
#include<iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
using namespace std;

/* sample input

*/
int n;
string str;

int main()
{
	cin >> str;
	int len = str.length();

	int count = 0;
	int answer = INT_MAX;
	for (int i = 0; i < 26; i++){
		count = 0;
		int tmax = 0;
		for (int j = 0; j < len; j++){
			if (str[j] != char('a' + i)){
				count++;
				tmax = max(tmax, count);
			}
			else{
				count = 0;
			}
		}
		answer = min(tmax, answer);
	}

	cout << answer;

	return 0;
}