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.Arrays;
import java.util.StringTokenizer;

public class Main {
    BufferedReader br;
    PrintWriter pw;
    StringTokenizer st;
    long LNF = Long.parseLong("9223372036854775807");
    String s;

    public static void main(String[] args) {
        (new Main()).run();
    }

    void solve() throws IOException {
        s = nextToken();
        pw.print(bins());
    }

    int bins() {
        int l = -1;
        int r = s.length();
        while (l + 1 != r) {
            int m = (l + r) / 2;
            if (r(m)) {
                r = m;
            } else l = m;
        }
        return r;
    }

    boolean r(int k) {
        int a[] = new int[26];
        int n = a.length;
        boolean b[] = new boolean[26];
        Arrays.fill(b, true);
        for (int i = 0; i < k; i++) {
            a[s.charAt(i) - 'a']++;
        }
        for (int i = 0; i < n; i++) {
            if (a[i] == 0) b[i] = false;
        }
        for (int i = k; i < s.length(); i++) {
            a[s.charAt(i) - 'a']++;
            a[s.charAt(i - k) - 'a']--;
            if (a[s.charAt(i - k) - 'a'] == 0) {
                b[s.charAt(i - k) - 'a'] = false;
            }
        }
        for (int i = 0; i < n; i++) {
            if (b[i]) return true;
        }
        return false;
    }

    void run() {
        try {
//            br = new BufferedReader(new FileReader("linear.in"));
            br = new BufferedReader(new InputStreamReader(System.in));
//            pw = new PrintWriter(new FileWriter("linear.out"));
            pw = new PrintWriter(new OutputStreamWriter(System.out));
            solve();
            pw.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

}