#include <iostream>

using namespace std;

int last[26];
int needs[26];

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

	for (int i=0; i<s.size(); i++) {
		needs[s[i]-'a'] = max(needs[s[i]-'a'],i-last[s[i]-'a']);
		last[s[i]-'a'] = i+1;
	}

	for (int i=0; i<26; i++) {
		needs[i] = max(needs[i],int(s.size())-last[i]);
	}

	int mn = s.size();
	for (int i=0; i<26; i++) {
		mn = min(mn,needs[i]);
	}

	cout << mn << "\n";
}
