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.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;


public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
//        InputStream inputStream = new FileInputStream("sum.in");
        OutputStream outputStream = System.out;
//        OutputStream outputStream = new FileOutputStream("sum.out");

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Answer solver = new Answer();
        solver.solve(in, out);
        out.close();
    }
}

class Answer {
    private final int INF = (int) (1e9 + 7);
    private final int MOD = (int) (1e9 + 7);
    private final int MOD1 = (int) (1e6 + 3);
    private final long INF_LONG = (long) (1e18 + 1);
    private final double EPS = 1e-9;

    private long gcd(long a, long b) {
        return (b == 0) ? a : gcd(b, a % b);
    }

    private long lcm(long a, long b) {
        return a * b / gcd(a, b);
    }


    private int bin(int l, int r, List<Integer>[] p, int n) {
        if (l > r) {
            return -1;
        }

        int k = (l + r) >> 1;

        for (int i = 0; i < 26; i++) {
            int psize = p[i].size();
            if (psize == 0) {
                continue;
            }

            boolean fl = true;
            for (int j = 0; j < psize - 1; j++) {
                int i1 = p[i].get(j);
                int i2 = p[i].get(j + 1);

                if (i2 - i1 > k) {
                    fl = false;
                    break;
                }
            }

            if (psize >= 1 && p[i].get(0) >= k) {
                fl = false;
            }

            int ilast = p[i].get(psize - 1);
            if (n - ilast > k) {
                fl = false;
            }

            if (fl) {
                int t = bin(l, k - 1, p, n);
                return (t == -1) ? k : t;
            }
        }

        return bin(k + 1, r, p, n);
    }

    public void solve(InputReader in, PrintWriter out) throws IOException {
        String s = in.next();

        int n = s.length();

        List<Integer>[] p = new List[26];
        for (int i = 0; i < 26; i++) {
            p[i] = new ArrayList<>();
        }

        for (int i = 0; i < n; i++) {
            int c = s.charAt(i) - 'a';
            p[c].add(i);
        }

        int k = bin(1, n, p, n);
        out.println(k);
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

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

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int[] nextArrayInt(int count) {
        int[] a = new int[count];
        for (int i = 0; i < count; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    public long[] nextArrayLong(int count) {
        long[] a = new long[count];
        for (int i = 0; i < count; i++) {
            a[i] = nextLong();
        }
        return a;
    }
}
