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

public class Main {
    public static void main(String[] args) {
        MyScanner in = new MyScanner();
        String str = in.next();

        Map<Character, Pair> map = new HashMap<>();
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            int ii = i;
            map.compute(c, (k, v) -> {
                if (v == null) v = new Pair(ii, ii + 1);
                else {
                    if (ii - v.i > v.max) v.max = ii - v.i;
                    v.i = ii;
                }
                return v;
            });
        }

        int min = Integer.MAX_VALUE;
        for (char k : map.keySet()) {
            Pair p = map.get(k);
            int locMax = p.max;
            if (str.length() - p.i > locMax) locMax = str.length() - p.i;
            min = Math.min(min, locMax);
        }

        System.out.println(min);
    }

    static class Pair {
        int i;
        int max;

        public Pair(int i, int max) {
            this.i = i;
            this.max = max;
        }
    }

    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            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;
        }
    }

}