import java.util.*;
public class main{
	public static void main (String[]Args ){
		
		Scanner sc = new Scanner(System.in);
		LinkedList<Character> list = new LinkedList();
		ArrayList<Boolean> pointer = new ArrayList();
		String a = sc.nextLine();
		for(int i = 0;i<a.length();i++){
			pointer.add(false);
			list.add(a.charAt(i));
		}
		int opera = 0;
		boolean delete=true;
		while (list.size()>2&&delete){
			delete=false;
			//System.out.print(list.size());
			if (list.size()>=2){
				if(list.get(1)!=list.get(0)){
					pointer.set(1,true);
					pointer.set(0,true);
				}
			}
			if (list.size()>=3){
				for(int i= 1;i<list.size()-1;i++){
					if(list.get(i)!=list.get(i+1)){
						pointer.set(i+1,true);
						pointer.set(i,true);
					}
				}
			}
			for(int i=pointer.size()-1;i>=0;i--){
				if (pointer.get(i)){
					pointer.remove(i);
					//System.out.println(i);
					list.remove(i);
					delete=true;	
				}
				//System.out.print(i);
			}
			if (delete){
				opera++;
			}
		}
		System.out.print(opera);
		
		
		
		
	}
}