use proconio::{fastout, input, marker::Chars};

#[fastout]
fn main() {
    input! {
        s: Chars
    };

    let mut s: Vec<char> = s;
    let mut count = 0;
    let mut flag = true;

    if s.len() >= 2 {
        while flag {
            let mut prev = s[0];
            let mut prev_i = 0;
            for i in 1..s.len() {
                if s[i] == '2' {
                    flag = false;
                    continue;
                }
                if s[i] != prev && prev != '2' {
                    s[i] = '2';
                    s[prev_i] = '2';
                    count += 2;
                    flag = true;
                } else {
                    prev = s[i];
                    prev_i = i;
                    flag = false;
                }
            }
        }
    }

    println!("{}", count);
}
