#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

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

	int ans = 1e9;
	for (char c = 'a'; c <= 'z'; c++) {
		int prev = -1;
		int len = 0;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == c) {
				len = std::max(len, i - prev - 1);
				prev = i;
			}
		}
		if (prev != -1) {
			len = std::max<int>(len, s.size() - prev - 1);
			ans = std::min(ans, len);
		}
	}
	std::cout << ans << std::endl;
}
