#include<iostream>
#include<algorithm>
using namespace std;

int main() {
	string s; cin >> s;
	int ans = (int)1e9;
	for (char c = 'a'; c <= 'z'; c++) {
		int cnt = 0, tmp = 0;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] != c)tmp++;
			else { cnt = max(cnt, tmp); tmp = 0; }
		}
		cnt = max(cnt, tmp);
		ans = min(ans, cnt);
	}
	cout << ans << endl;

	return 0;
}