import std.algorithm;
import std.range;
import std.stdio;
import std.string;

immutable int letters = 26;

void main ()
{
	string s;
	while ((s = readln.strip) != "")
	{
		auto a = new int [] [letters];
		foreach (i, c; s.map !(x => x - 'a').array)
		{
			a[c] ~= i;
		}
		int n = cast (int) (s.length);
		int res = int.max;
		foreach (b; a.filter !(x => !x.empty))
		{
			debug {writeln (b);}
			int cur = b[0];
			foreach (j; 1..b.length)
			{
				cur = max (cur, (b[j] - b[j - 1] - 1));
			}
			cur = max (cur, n - b[$ - 1] - 1);
			res = min (res, cur);
		}
		writeln (res);
	}
}
