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)");

        ArrayList<Integer> answer = new ArrayList<Integer>();
        int a =0,b=100;
        
        if(parts.length >1) {
            
            for (int i=0; i<parts.length ; i++) {
                answer.add(parts[i].length());
            }
        
        while (b!=0) {
            for(int j=0 ; j<parts.length ; j++) {
                b=0;
                if(answer.get(j)>=1 && (j==0 || j== (parts.length-1) ) ) {
                    answer.set(j,answer.get(j)-1);
                    b--;
                }else if(answer.get(j)>=1 && (j<parts.length-1 || 0<j ) ) {
                    answer.set(j,answer.get(j)-2);
                    b--;
                }
                
                
            }
            if(b<0){a++;}
        
        
        
        
        }
        System.out.println(a);
        }else{System.out.println(0);}
            
        }
}