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.IOException;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main 
{

	public static void main(String[] args) throws NumberFormatException, IOException 
	{
		int[][] arr=new int[26][2];
		Reader s=new Reader(System.in);
		String str=s.next();
		for(int a=0;a<str.length();a++)
		{
			int index=str.charAt(a)-'a';
			if(a+1-arr[index][0]>arr[index][1])
				arr[index][1]=a+1-arr[index][0];
			arr[index][0]=a+1;
		}
		for(int a=0;a<26;a++)
		{
			if(str.length()+1-arr[a][0]>arr[a][1])
				arr[a][1]=str.length()+1-arr[a][0];
		}
		int min=Integer.MAX_VALUE;
		for(int a=0;a<26;a++)
		{
			if(arr[a][1]<min)
				min=arr[a][1];
		}
		System.out.println(min);
	}

}
class Reader 
{
	private BufferedReader reader;
	private StringTokenizer tokenizer;
	
	public Reader(InputStream input)
	{
		reader=new BufferedReader(new InputStreamReader(input));
		tokenizer=new StringTokenizer("");
	}
	public String next() throws IOException
	{
		while(tokenizer.hasMoreTokens()==false)
		{
			tokenizer=new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
	public String nextLine() throws IOException
	{
		return reader.readLine();
	}
	public int nextInt() throws NumberFormatException, IOException
	{
		return Integer.parseInt(next());
	}
	public double nextDouble() throws NumberFormatException, IOException
	{
		return Double.parseDouble(next());
	}
	public long nextLong() throws NumberFormatException, IOException
	{
		return Long.parseLong(next());
	}
}


 		 	 		 		 		  			 	  		 			