import java.util.*;




public class codeforces {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
        String N = in.nextLine();
        
        String[] parts = N.split("(?<=(.))(?!\\1)");
        TreeSet<Integer> answer = new TreeSet<Integer>();
        ArrayList<Integer> ranswer = new ArrayList<Integer>();
        int a =0;
        
        if(parts.length >1) {
            
            for (int i=0; i<parts.length ; i++) {
                answer.add(parts[i].length());
            }
        ranswer.addAll(answer);
        a = ranswer.size();
        System.out.println(ranswer.get(a-1));
        
        }else{System.out.println(0);}
            
        }
}