#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[110]="";
	scanf("%s",s+1);
	int n=strlen(s+1),ans=1e9;
	for (char ch='a';ch<='z';ch++){
		int val=0;
		int last=1;
		for (int i=1;i<=n;i++)
		if (s[i]==ch){
			val=max(val,i-last);
			last=i+1;
		}
		if (last<=n) val=max(val,n+1-last);
		ans=min(ans,val);
	}
	printf("%d\n",ans);
	return 0;
}