import java.util.Scanner;

/**
 * Created by Jarek on 2018-01-01.
 */
public class ColorFulPoints {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String input = scanner.nextLine();
        //String input = "aaaaaaaaaaabbbbbbbbaa";
        char[] inputArr = input.toCharArray();
        boolean somethingRemoved = true;
        int counter = 0;
        while (somethingRemoved) {
            somethingRemoved = false;
            boolean[] remArr = new boolean[inputArr.length];
            char[] newArray = new char[inputArr.length];

            for (int i = 0, newIndex = 0; i < inputArr.length - 1; ) {
                if (inputArr[i] == '\u0000' || inputArr[i + 1] == '\u0000') break;
                if (inputArr[i] != inputArr[i + 1]) {
                    remArr[i] = true;
                    remArr[i + 1] = true;
                    i += 2;
                    somethingRemoved = true;
                } else {
                    newArray[newIndex++] = inputArr[i++];
                }
            }
//            int newIndex = 0;
//            for (int i = 0; i < inputArr.length; i++) {
//                if(inputArr[i] == '\u0000') break;
//                if(!remArr[i]) {
//                    newArray[newIndex++] = inputArr[i];
//                } else {
//
//                }
//            }
            inputArr = newArray;
            if (somethingRemoved) {
                counter++;
            }

        }
        System.out.println(counter);
    }
}
