#include <iostream>

using namespace std;

const int kInf = 1e9;

void Solve() {
	string s;
	cin >> s;

	int ans = kInf;

	for (char c = 'a'; c <= 'z'; ++c) {
		int tans = 0;
		int last = s.length();

		for (int j = s.length() - 1; j >= 0; --j) {
			if (s[j] == c) {
				tans = max(tans, last - j - 1);
				last = j;
			}
		}
		tans = max(tans, last);
		ans = min(ans, tans);
	}

	cout << ans << "\n";
}

int main() {
	int tests = 1;
	for (;tests; --tests) {
		Solve();
	}
}