
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        StringBuilder s = new StringBuilder(in.next());
        int r = 0;
        while (true) {
            if(s.length()==0){
                System.out.println(r);
                return;
            }
            int l = s.length();
            for (int i = 0; i < s.length(); i++) {
                boolean deleted = false;
                if (i > 0 && s.charAt(i) != s.charAt(i - 1)) {
                    s.deleteCharAt(i - 1);
                    deleted = true;
                }
                if (deleted) {
                    int k = --i;
                    if (k < s.length() - 1 && s.charAt(k) != s.charAt(k + 1)) {
                        s.deleteCharAt(k + 1);
                    }
                } else {
                    if (i < s.length() - 1 && s.charAt(i) != s.charAt(i + 1)) {
                        s.deleteCharAt(i + 1);
                    }
                }
            }
            if(l==s.length()){
                System.out.println(r);
                return;
            }
            r++;
        }
    }
}