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.*;
import java.util.*;

public class Competitive_1 {
	
	public static void main(String[] args) {
		FastReader in = new FastReader();
		String s = in.next();
		int last[] = new int[26];
		int max[] = new int[26];
		int ans = Integer.MAX_VALUE;
		
		Arrays.fill(last, -1);
		for(int i=0; i<s.length(); i++){
			char x = s.charAt(i);
			max[x-'a'] = Math.max(max[x-'a'], i-last[x-'a']);
			last[x-'a'] = i;
		}
		
		for(int i=0; i<26; i++){
			if(max[i]!=0){
				max[i] = Math.max(max[i], s.length()-last[i]);
				ans = Math.min(ans, max[i]);
			}
		}
		
		System.out.println(ans);
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
	
	
}
