import java.util.*;

public class test{
	
	static int count=0;
	public static void main(String[] args){
		Scanner s =new Scanner(System.in);
		String a=s.nextLine();
		while(true){
			String b=generateString(a);
			if(a.length()==b.length() || b.length()==0)
				break;
			a=b;
		}
		System.out.println(count);
	}
	
	static String generateString(String a){
		count++;
		String c=a;
		String b="";
		for(int i=0;i<a.length();i++){
			if(i==0){
				if(a.length()>1){
				if(a.charAt(1)==a.charAt(0))
					b=b+a.charAt(0);
				}
			}
			else if(i==a.length()-1){
				if(a.charAt(a.length()-1)==a.charAt(a.length()-2))
					b=b+a.charAt(a.length()-1);
			}
			else if(a.charAt(i-1)==a.charAt(i+1)){
				b=b+a.charAt(i);
			}
			else {}
		}
		if(b.length()==c.length())
			count--;
		return b;
	}
}