#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let s = read::<String>();
    let n = s.len();
    if n < 2 {
        println!("{}", 0);
        return;
    }

    let mut v = s.chars().collect::<Vec<char>>();
    let mut count = 0;

    loop {
        let len = v.len();
        if len == 0 {break;}
        for i in 0..len-1 {
            if v[i] == 'X' {
                continue;
            } else if v[i+1] != 'X' && v[i] != v[i+1] {
                v[i] = 'X';
                v[i+1] = 'X';
            }
        }

        let xcount = v.iter().filter(|&c| *c=='X').count();
        if xcount == 0 {
            break;
        } else {
            count += xcount;
        }
        v = v.iter().filter(|&c| *c!='X').map(|&c| c).collect::<Vec<char>>();
    }

    println!("{}", count);

    /*
    let mut f = false;
    let mut a = v[0];
    let mut count = 1;
    let mut total = 0;
    for i in 1..n {
        if f == false { // 準備フェーズ
            if v[i] == a {
                count += 1;
            } else {
                a = v[i];
                f = !f;
                total += 2;
                count -= 1;
            }
        } else { // 回収フェーズ
            if v[i] == a {
                if count == 0 {
                    f = !f;
                    count += 1;
                } else {
                    total += 2;
                    count -= 1;
                }
            } else {
                f = !f;
                count = 1;
            }
        }
    }
    println!("{}", total);
    */


    /* vec input
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];
    let c = v[2];
    */

    /* loop pattern
    let mut count = 0;
    loop {
        if  { break; }
        count += 1;
    }
    println!("{}", count);
    */

    /* yes/no pattern
    yn(a == b);
    */
}
