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.*;
import java.lang.*;
import java.math.*;
public class C {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        // Scanner scan = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        // int n = Integer.parseInt(bf.readLine());
        // StringTokenizer st = new StringTokenizer(bf.readLine());
        // int n =  Integer.parseInt(st.nextToken());
        String s = bf.readLine();
        int[] counters = new int[26];
        int[] max = new int[26];
        for(int i=0; i<s.length(); i++) {
          for(int j=0; j<26; j++)
            counters[j]++;
          counters[s.charAt(i)-'a'] = 0;
          for(int j=0; j<26; j++)
            if(counters[j] > max[j]) max[j] = counters[j];

        }
        int min = 10000000;
        for(int i=0; i<26; i++) if(max[i] < min) min = max[i];
        out.println((min+1));

        out.close(); System.exit(0);
    }


}
