#include <cstdio>
#include <algorithm>
char s[101];
int a[100], N, O = 101;
int check()
{
	int L = N;
	while (std::count(a, a + L, 1) != L)
	{
		for (int i = 0; i < L - 1; i++)
			a[i] |= a[i + 1];
		L--;
	}
	return N - L;
}
int main()
{
	scanf("%s", s);
	while (s[N])
		N++;
	for (char i = 'a'; i <= 'z'; i++)
	{
		for (int j = 0; j < N; j++)
			a[j] = s[j] == i;
		O = std::min(O, check());
	}
	printf("%d\n", O);
	return 0;
}
