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

typedef long long ll;

#define N 1010

char S[N];
int last[30];
vector<int> f[N];

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

		
int main()
{
	scanf("%s",S+1);
	int len=(int)strlen(S+1),Ans=len;
	for(int i=1;i<=len;i++)
	{
		int now=S[i]-'a';
		f[now].push_back(i);
	}
	for(int i=0;i<26;i++)
	{
		if(!f[i].size())
			continue;
		int Max=f[i][0]-1;
		for(int j=1;j<f[i].size();j++)
			Max=max(Max,f[i][j]-f[i][j-1]-1);
		Max=max(Max,len-f[i][f[i].size()-1]);
		Ans=min(Ans,Max);
	}
	cout<<Ans<<endl;
	return 0;	
}