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.*;

public class main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		int lo = 1, hi = s.length();
		while(hi > lo) {
			int mid = lo + (hi - lo) / 2;
			if(work(s, mid)) hi = mid;
			else lo = mid + 1;
		}
		System.out.println(lo);
	}
	
	public static boolean work(String s, int mid) {
		HashSet<Character> c = new HashSet<>();
		for(int i=0;i<s.length();i++) {
			if(!c.contains(s.charAt(i))) {
				c.add(s.charAt(i));
				if(workEach(s, mid, s.charAt(i))) return true;
			}
		}
		return false;
	}
	
	public static boolean workEach(String s, int mid, char c) {
		for(int i=0;i<s.length()-mid+1;i++) {
			String sb = s.substring(i, i+mid);
			int index = sb.lastIndexOf(c);
			if(index == -1) return false;
			else i += index;
		}
		return true;
	}
}
