#include <bits/stdc++.h>
using namespace std;

char str[105];

int main()
{	
	cin >> str+1;
	int ans = strlen(str+1);
	int n = strlen(str+1);
	for (char i = 'a'; i <= 'z'; i++) {
		int last = 0, cur = 0;
		for (int j = 1; j <= n; j++)
			if (str[j] == i) {
				cur = max(cur, j-last-1);
				last = j;
			}
		cur = max(cur, n+1-last-1);
		ans = min(ans, cur);
	}
	cout << ans << endl;
	return 0;
}
