import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class CodeForces {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();
        scanner.close();

        int moves = 0;
        boolean work = input.length() > 1;
        while (work) {
            work = false;

            Set<Integer> remove = new HashSet<>();
            for (int i = 1; i < input.length(); i++) {
                if (input.charAt(i) == input.charAt(i - 1)) {
                    remove.add(i);
                    remove.add(i - 1);
                    work = true;
                }
            }
            if (work) {
                moves++;
                StringBuilder next = new StringBuilder();
                for (int i = 0; i < input.length(); i++) {
                    if (!remove.contains(i)) {
                        next.append(input.charAt(i));
                    }
                }
                input = next.toString();
            }
        }

        System.out.println(moves);
    }
}