
fn func(input_str: &str) -> u32 {
    let mut s = input_str.chars().collect::<Vec<_>>();
    let mut ans = 0;
    loop {
        let mut s_buf = Vec::new();
        let mut idx = 0;
        while idx < s.len() - 1 {
            if s[idx] != s[idx + 1] {
                idx += 2;
                ans += 2;
            } else {
                s_buf.push(s[idx]);
                idx += 1
            }
        }
        if idx == s.len() - 1 {
            s_buf.push(s[idx]);
        }
        if s_buf.len() == s.len() || s_buf.len() == 0 {
            return ans;
        }
        s = s_buf;
    }
}

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    println!("{}", func(&buf[..]));
}
