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.util.*;
import java.io.*;
import java.math.*;
import java.lang.*;
import java.util.stream.*;

/**
 * @author Pradyumn
 */

public class C implements Runnable{
	public int TC = 0;
	public static void main(String[] args) {
		new Thread(null, new C(), ":)", 1L << 26).start();
	}
	
	@SuppressWarnings("Unchecked")
	public void solve() throws IOException {
		char[] s = ns(100000);
		int n = s.length;
		TreeSet<Integer>[] sets = new TreeSet[26];
		for(int i = 0;i < 26; ++i)
			sets[i] = new TreeSet<>();
		for(int i = 0;i < n; ++i)
			sets[s[i] - 'a'].add(i);
		int minLen = n;
		for(int i = 0;i < 26; ++i) {
			if(sets[i].isEmpty()) continue;
			Integer ff = sets[i].pollFirst();
			Integer ss = null;
			int minDiff = ff + 1;
			while(!sets[i].isEmpty()) {
				ss = sets[i].pollFirst();
				minDiff = Math.max(minDiff, ss - ff);
				ff = ss;
			}
			minDiff = Math.max(minDiff, n - ff);
			minLen = Math.min(minLen, minDiff);
		}
		out.println(minLen);
	}
	
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in),32768);
			st = null;
			out = new PrintWriter(System.out);
			if(TC == 1) {
				for(int T = ni();T > 0; --T) {
					solve();
				}
			} else {
				solve();
			}
			br.close();
			out.close();
		} catch(IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
	public char[] ns(int n) throws IOException {
		return ns().toCharArray();
	}
	public char[][] nm(int n, int m) throws IOException {
		char[][] map = new char[n][];
		for(int i = 0;i < n; ++i) {
			map[i] = ns(m);
		}
		return map;
	}
	public String ns() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(br.readLine());
		}
		return st.nextToken();
	}
	public String nextLine() throws IOException {
		return br.readLine();
	}
	public int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	public int[] na(int n) throws IOException {
		int[] a = new int[n];
		for(int i = 0;i < n; ++i) a[i] = ni();
		return a;
	}

	public long nl() throws IOException {
		return Long.parseLong(ns());
	}

	public long[] nal(int n) throws IOException {
		long[] a = new long[n];
		for(int i = 0;i < n; ++i) a[i] = nl();
		return a;
	}

	public double nd() throws IOException {
		return Double.parseDouble(ns());
	}
	private static boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private static void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); } 
}
