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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CKDominantCharacter solver = new CKDominantCharacter();
        solver.solve(1, in, out);
        out.close();
    }

    static class CKDominantCharacter {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            char[] arr = sc.next().toCharArray();
            int l = 1, h = arr.length;
            while (l <= h) {
                int mid = (l + h) / 2;
                if (check(mid, arr))
                    h = mid - 1;
                else
                    l = mid + 1;
            }
            pw.println(h + 1);
        }

        private boolean check(int mid, char[] arr) {
            int[] c = new int[26];
            int msk = 0;
            for (int i = 0; i < arr.length; i++) {
                if (i < mid) {
                    msk |= 1 << (arr[i] - 'a');
                    c[arr[i] - 'a']++;
                } else {
                    if ((msk & (1 << (arr[i - mid] - 'a'))) != 0)
                        c[arr[i - mid] - 'a']--;
                    if ((msk & (1 << (arr[i] - 'a'))) != 0)
                        c[arr[i] - 'a']++;
                    if (c[arr[i - mid] - 'a'] == 0)
                        c[arr[i - mid] - 'a'] = (int) -1e9;
                }
            }
            for (int i = 0; i < 26; i++) {
                if ((msk & (1 << i)) != 0 && c[i] > 0)
                    return true;
            }
            return false;
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}

