#include<iostream>
#include<algorithm>
#include<string>
std::string S;
int ans = 1 << 30;
int main() {
	std::cin >> S;
	for (int i = 0; i < 26; i++) {
		char ser = 'a' + i;
		int sum = 0;
		int max = 0;
		for (auto u : S) {
			if (u == ser)max = std::max(sum, max), sum = -1;
			sum++;
		}
		max = std::max(sum, max);
		ans = std::min(ans, max);
	}
	std::cout << ans << std::endl;
	return 0;
}