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.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Solution {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		String input = in.nextLine();
		int[][] letters = new int [26][2];
		int n = input.length();
		for (int i = 0; i < input.length(); i++) {
			int x = (int)input.charAt(i) - (int)'a';
			
			if(i + 1- letters[x][0] > letters[x][1] )
				letters[x][1] = i + 1- letters[x][0];
			letters[x][0] = i +1;
		}
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < 26; i++) {
			if(n + 1- letters[i][0] > letters[i][1] )
				letters[i][1] = n + 1 - letters[i][0];
			
		}
		for (int i = 0; i < 26; i++) {
			if (min > letters[i][1]) {
				min = letters[i][1];
			}
		}
		
		System.out.println(min);
	}
	
}

class InputReader {
	BufferedReader reader;
	StringTokenizer tokenizer;

	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream));
		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 long nextLong() {
		return Long.parseLong(next());
	}

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

}