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.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class temp
{
	boolean possible(int k,int a[][])
	{
		for(int i=0;i<26;i++)
		{
			boolean f = true;
			for(int j=0;j<=a.length-k;j++)
			{
				int d = a[j+k-1][i] - (j-1>=0? a[j-1][i]:0);
				if(d==0)
				{
					f = false;
					break;
				}
			}
			if(f)
				return true;
		}
		
		return false;
	}
	
	void solve()
	{
		FastReader sc =new FastReader();
		String s = sc.next();
		int n = s.length();
		
		int a[][] = new int[n][26];
		
		for(int i=0;i<n;i++)
		{
			if(i!=0)
			{
				for(int j=0;j<26;j++)
					a[i][j] = a[i-1][j];
			}
			a[i][s.charAt(i)%97]++;
		}
		
		int l = 1,r = n;
		int k = 0;
		
		while(l<=r)
		{
			int mid = (l+r)/2;
			if(possible(mid,a))
			{
				k = mid;
				r = mid-1;
			}
			else
				l = mid+1;
		}
		
		System.out.println(k);
	}
 
    public static void main(String[] args)
    {
        new temp().solve();
    }
	
    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;
        }
    }
} 