You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c.

You have to find minimum k such that there exists at least one k-dominant character.

Input

The first line contains string s consisting of lowercase Latin letters (1 ≤ |s| ≤ 100000).

Output

Print one number — the minimum value of k such that there exists at least one k-dominant character.

Examples

Input

abacaba


Output

2


Input

zzzzz


Output

1


Input

abcde


Output

3
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class C {
public static boolean isDominant(String s,int n)
{
	int []count =new int [26];
	/*if(n==1)
	{
		char c=s.charAt(0);
		for(char x:s.toCharArray())
			if(x!=c)
				return false;
		return true;
	}*/
	for(int i=0;i<n;i++)
		count [s.charAt(i)-'a']++;
	
	for(int i=1;i+n<=s.length();i++)
	{
		int prev=s.charAt(i-1)-'a';
		int curr=s.charAt(i+n-1)-'a';
		
		if(curr!=prev)
		{
			count [prev]--;
			if(count [curr]>0)
				count[curr]++;
		}
		
		
	}
	for(int i=0;i<26;i++)
		if(count [i]>0)
			return true;
	return false;
	
}
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();int n=s.length();
		int lo=1;int hi=n;
		int ans=0;
		
		while(lo<=hi )
		{
			
			int mid=(lo+hi)/2;		
			if(isDominant(s,mid))
			{
				hi=mid-1;
				ans=mid;
				
			}
			else
				lo=mid+1;
			
		}
		
		System.out.println(ans);
	}

}
class Scanner 
{
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

	public String next() throws IOException 
	{
		while (st == null || !st.hasMoreTokens()) 
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {return Integer.parseInt(next());}
	
	public long nextLong() throws IOException {return Long.parseLong(next());}

	public String nextLine() throws IOException {return br.readLine();}
	
	public double nextDouble() throws IOException
	{
		String x = next();
		StringBuilder sb = new StringBuilder("0");
		double res = 0, f = 1;
		boolean dec = false, neg = false;
		int start = 0;
		if(x.charAt(0) == '-')
		{
			neg = true;
			start++;
		}
		for(int i = start; i < x.length(); i++)
			if(x.charAt(i) == '.')
			{
				res = Long.parseLong(sb.toString());
				sb = new StringBuilder("0");
				dec = true;
			}
			else
			{
				sb.append(x.charAt(i));
				if(dec)
					f *= 10;
			}
		res += Long.parseLong(sb.toString()) / f;
		return res * (neg?-1:1);
	}
	
	public boolean ready() throws IOException {return br.ready();}


}