import java.lang.*;
import java.io.*;
import java.util.*;

public class Main {

    class Pair {
        int l, r, type;

        Pair(int l, int r, int type) {
            this.l = l;
            this.r = r;
            this.type = type;
        }
    }

    public void solve() throws IOException {
        char s[] = nextToken().toCharArray();
        int n = s.length;
        int lvl[] = new int[n];
        Queue<Pair> q = new LinkedList<>();
        int b = 0, e = 0;
        for (int i = 1; i < n; i++) {
            if(s[i] == s[i - 1]){
                if(b == 0 && e == 0){}
                else {
                    q.add(new Pair(b, e, 1));
                }
                b = i;
            }else {
                lvl[i - 1] = 1;
                lvl[i] = 1;
                e = i;
            }
        }
        while (!q.isEmpty()){
            Pair p = q.poll();
            int bb = p.l, ee = p.r;
            if(p.l > 0 && lvl[p.l - 1] == 0){
                lvl[p.l - 1] = p.type + 1;
                bb--;
            }
            if(p.r < n - 1 && lvl[p.r + 1] == 0){
                ee++;
                lvl[p.r + 1] = p.type + 1;
            }
            if(bb != p.l || ee != p.r){
                q.add(new Pair(bb, ee, p.type + 1));
            }
        }
        int max = 0;
        for (int i = 0; i < n; i++) {
            max = Math.max(max, lvl[i]);
        }
        out.print(max);
    }

    BufferedReader br;
    StringTokenizer sc;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new Main().run();
    }

    void run() throws IOException {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
//            br = new BufferedReader(new FileReader("pnumbers.in"));
//            out = new PrintWriter(new File("out.txt"));
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    String nextToken() throws IOException {
        while (sc == null || !sc.hasMoreTokens()) {
            try {
                sc = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return sc.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

}