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.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Arrays;

public class C888 {
	
	int n;
	char[] s;
	
	boolean check(int len) {
		boolean[] zero = new boolean[256];
		Arrays.fill(zero, true);
		int[] f = new int[256];
		for(int i = 0; i < len; ++i) {
			f[s[i]]++;
			zero[s[i]] = false;
		}
		for(int l = 0, r = len; r < n; ++l, ++r) {
			f[s[l]]--;
			f[s[r]]++;
			if(f[s[l]] == 0) zero[s[l]] = true;
		}
		for(int i = 0; i < 256; ++i) if(!zero[i]) return true;
		return false;
	}
	
	public void solve(JoltyScanner in, PrintWriter out) {
		s = in.next().toCharArray();
		n = s.length;
		int lo = 1, hi = n;
		while(lo <= hi) {
			int m = lo + hi >> 1;
			if(check(m)) hi = m - 1;
			else lo = m + 1;
		}
		out.println(lo);
	}
	
	public static void main(String[] args) {
		JoltyScanner in = new JoltyScanner();
		PrintWriter out = new PrintWriter(System.out);
		new C888().solve(in, out);
		out.close();
	}
	
	static class JoltyScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public JoltyScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public JoltyScanner(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
	        while(c!='.'&&c!='-'&&(c <'0' || c>'9')) c = nextChar();
	        boolean neg = c=='-';
	        if(neg)c=nextChar();
	        boolean fl = c=='.';
	        double cur = nextLong();
	        if(fl) return neg ? -cur/num : cur/num;
	        if(c == '.') {
	            double next = nextLong();
	            return neg ? -cur-next/num : cur+next/num;
	        }
	        else return neg ? -cur : cur;
	    }

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
	}

}
