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.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            char[] a = in.next().toCharArray();
            int n = a.length;
            int lo = -1, hi = n;
            while (hi - lo > 1) {
                int m = lo + (hi - lo) / 2;
                if (count(a, m) == 0) {
                    lo = m;
                } else {
                    hi = m;
                }
            }
            out.println(hi);
        }

        private int count(char[] a, int k) {
            int n = a.length;
            int[] c = new int[26];
            int mask = 0;
            for (int i = 0; i < k; ++i) {
                int pos = a[i] - 'a';
                ++c[pos];
                mask |= 1 << pos;
            }
            int ret = mask;
            for (int i = k; i < n; ++i) {
                int pos = a[i - k] - 'a';
                --c[pos];
                if (c[pos] == 0) {
                    mask &= ~(1 << pos);
                }
                pos = a[i] - 'a';
                ++c[pos];
                mask |= 1 << pos;
                ret &= mask;
            }

            return Integer.bitCount(ret);
        }

    }

    static class FastScanner {
        BufferedReader in;
        StringTokenizer token;
        String delim;

        public FastScanner(InputStream inputStream) {
            this.in = new BufferedReader(new InputStreamReader(inputStream));
            this.delim = " \n\t";
            this.token = new StringTokenizer("", delim);
        }

        public FastScanner(InputStream inputStream, String delim) {
            this.in = new BufferedReader(new InputStreamReader(inputStream));
            this.delim = delim;
            this.token = new StringTokenizer("", delim);
        }

        public boolean hasNext() {
            while (!token.hasMoreTokens()) {
                try {
                    String s = in.readLine();
                    if (s == null) return false;
                    token = new StringTokenizer(s, delim);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return true;
        }

        public String next() {
            hasNext();
            return token.nextToken();
        }

    }
}

