#include <iostream>
#include <string>
#include <algorithm>

int used[26];

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

	int ans = 10000000;
	for (char target = 'a'; target <= 'z'; ++target) {
		auto s = str;
		int res = 0;
		for (; std::count(s.begin(), s.end(), target) != s.size(); ++res) {
			for (int i = 0; i < s.size() - 1; ++i) {
				if (s[i + 1] == target)
					s[i] = target;
			}

			s.pop_back();
		}

		ans = std::min(ans, res);
	}
	
	std::cout << ans << std::endl;
}