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.InputMismatchException;
import java.io.IOException;
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;
        InputReader in = new InputReader(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, InputReader in, PrintWriter out) {
            Thread t = new Thread(null, new TaskCThread(in, out), "1", 1 << 23);
            t.start();
            try {
                t.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }

    static class TaskCThread implements Runnable {
        InputReader in;
        PrintWriter out;

        TaskCThread(InputReader in, PrintWriter out) {
            this.in = in;
            this.out = out;
        }

        public void run() {
            char c[] = in.next().toCharArray();
            int l = 1, n = c.length, r = n, ans = r;
            while (l <= r) {
                int mid = (l + r) / 2;
                if (check(c, mid)) {
                    r = mid - 1;
                    ans = mid;
                } else {
                    l = mid + 1;
                }
            }
            out.println(ans);
        }

        private boolean check(char[] c, int mid) {
            int ans = 0, cr = 0;
            int ct[] = new int[26];
            for (int i = 0; i < c.length; i++) {
                if (i < mid) {
                    int cv = c[i] - 'a';
                    ct[cv]++;
                    if (ct[cv] == 1) {
                        ans |= 1 << cv;
                        cr = ans;
                    }
                } else {
                    int cv = c[i] - 'a', cvv = c[i - mid] - 'a';
                    ct[cv]++;
                    ct[cvv]--;
                    if (ct[cv] == 1) {
                        cr |= 1 << cv;
                    }
                    if (ct[cvv] == 0) {
                        cr ^= 1 << cvv;
                    }
                    ans &= cr;
                }
            }
            if (ans > 0) {
                return true;
            }
            return false;
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

