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.*;
import java.util.Map.Entry;
import java.lang.Math;
import java.math.BigInteger;

public class Problem {
	
	void solve() throws IOException {
		
		
		char[] s = rS().toCharArray();
		int n = s.length;
		
		
		
		int ans = 1000*1000;
		for(int i=0;i<26;++i){
			int l=0;
			int r = n;
			char cur = (char)('a'+i);
			while(r-l>1){
				boolean flag = true;
				int count=0;
				int mid = (r+l)/2;
				for(int j=0;j<mid;++j){
					if(s[j]==cur){
						count++;
					}
				}
				if(count==0){
					flag=false;
				}
				for(int j=mid;j<n;++j){
					if(s[j-mid]==cur){
						count--;
					}
					if(s[j]==cur){
						count++;
					}
					if(count==0){
						flag=false;break;
					}
				}
				if(flag){
					r = mid;
				}else{
					l=mid;
				}
			}
			ans = Math.min(ans, r);
		}
		out.println(ans);
	}
	
	
	class SegmentTree{
		int[] t;
		
		SegmentTree(int[] a, int n){
			t = new int[4*n];
			build(a, 1, 1, n);
		}
		
		void build(int[] a, int v, int tl, int tr){
			if(tl==tr){
				t[v] = a[tl]; return;
			}
			
			int tm = (tl+tr)/2;
			build(a, 2*v, tl, tm);
			build(a, 2*v+1, tm+1, tr);
			t[v] = Math.min(t[2*v], t[2*v+1]);
		}
		
		void update(int v, int tl, int tr, int pos, int value){
			if(tl==tr){
				t[v] = value; return;
			}
			int tm = (tl+tr)/2;
			if(pos<=tm){
				update(2*v, tl, tm, pos, value);
			}else{
				update(2*v+1, tm+1, tr, pos, value);
			}
			
			t[v] = Math.min(t[2*v], t[2*v+1]);
		}
		
		int getMin(int v, int tl, int tr, int l, int r){
			if(l>r){
				return INF;
			}
			if(tl==l&&tr==r){
				return t[v];
			}
			
			int tm = (tl+tr)/2;
			
			int min1 = getMin(2*v, tl, tm, l, Math.min(tm, r));
			int min2 = getMin(2*v+1, tm+1, tr, Math.max(l, tm+1), r);
			
			return Math.min(min1, min2);
		}
	}
	
	
	int checkBit(int mask, int bit) {
		return (mask >> bit) & 1;
	}

	public static void main(String[] args) throws IOException {

		new Problem().run();
	}

	boolean isLower(char a) {
		return ((int) a) >= 97 ? true : false;
	}

	int INF = Integer.MAX_VALUE - 12345;

	int[][] STEPS = { { 0, 1 }, { 1, 0 }, { -1, 0 }, { 0, -1 } };

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok;
	Random rnd = new Random();
	static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

	Problem() throws FileNotFoundException {
		
		try{
			in = new BufferedReader(new FileReader("input.txt"));
			out = new PrintWriter("output.txt");
		}catch(Exception e){
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		}
		
		tok = new StringTokenizer("");
	}

	long checkBit(long mask, int bit) {
		return (mask >> bit) & 1;
	}

	// ======================================================

	// ======================================================
	void run() throws IOException {
		solve();
		out.close();
	}

	char[] reverseCharArray(char[] arr) {
		char[] ans = new char[arr.length];
		for (int i = 0; i < arr.length; ++i) {
			ans[i] = arr[arr.length - i - 1];
		}
		return ans;
	}

	int sqrt(double m) {
		int l = 0;
		int r = 1000000000 + 9;
		int i = 1000;
		while (r - l > 1) {
			int mid = (r + l) / 2;
			if (mid * mid > m) {
				r = mid;
			} else {
				l = mid;
			}
		}
		return l;
	}
	
	int countPow(int m, int n) {
		int ans = 0;
		while (m % n == 0 && m > 0) {
			ans++;
			m /= n;
		}
		return ans;
	}

	long binPow(long a, long b) {
		if (b == 0) {
			return 1;
		}
		if (b % 2 == 1) {
			return a * binPow(a, b - 1);
		} else {
			long c = binPow(a, b / 2);
			return c * c;
		}

	}

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

	long pow(long x, long k) {
		long ans = 1;
		for (int i = 0; i < k; ++i) {
			ans *= x;
		}
		return ans;
	}
	
	class Fenwik{
		private long[] t;
		private int length;
		
		Fenwik(int[] a){
			this.length = a.length+100;
			this.t = new long[length];
			for(int i=0;i<a.length;++i){
				this.inc(i, a[i]);
			}
		}
		
		void inc(int i, int delta){
			for(; i<this.length; i=i|(i+1)){
				this.t[i] += delta;
			}
		}
		
		long getSum(int r){
			long sum = 0;
			
			for(;r>=0;r=(r&(r+1))-1){
				sum+= this.t[r];
			}
			
			return sum;
		}
	}
	
	// ////////////////////////////////////////////////////////////////////

	String delimiter = " ";

	String readLine() throws IOException {
		return in.readLine();
	}

	String rS() throws IOException {
		while (!tok.hasMoreTokens()) {
			String nextLine = readLine();
			if (null == nextLine)
				return null;

			tok = new StringTokenizer(nextLine);
		}

		return tok.nextToken(delimiter);
	}

	int rI() throws IOException {
		return Integer.parseInt(rS());
	}

	long rL() throws IOException {
		return Long.parseLong(rS());
	}

	double rD() throws IOException {
		return Double.parseDouble(rS());
	}

	int[] rA(int b) {
		int a[] = new int[b];
		for (int i = 0; i < b; i++) {
			try {
				a[i] = rI();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return a;
	}

	int[] readSortedIntArray(int size) throws IOException {
		Integer[] array = new Integer[size];

		for (int index = 0; index < size; ++index) {
			array[index] = rI();
		}
		Arrays.sort(array);

		int[] sortedArray = new int[size];
		for (int index = 0; index < size; ++index) {
			sortedArray[index] = array[index];
		}

		return sortedArray;
	}

	int[] sortedIntArray(int size, int[] array) throws IOException {
		for (int index = 0; index < size; ++index) {
			array[index] = rI();
		}
		Arrays.sort(array);

		int[] sortedArray = new int[size];
		for (int index = 0; index < size; ++index) {
			sortedArray[index] = array[index];
		}

		return sortedArray;
	}
}