use whiteread::parse_line;

fn main() {
    let s: String = parse_line().unwrap();
    let mut s: Vec<Option<char>> = s.chars().map(|x| Some(x)).collect();
    let mut ans = 0;

    while !s.is_empty() {
        let mut cnt = 0;
        for i in 0..s.len() - 1 {
            if let Some(c) = s[i] {
                if let Some(d) = s[i + 1] {
                    if c != d {
                        cnt += 2;
                        s[i] = None;
                        s[i + 1] = None;
                    }
                }
            }
        }
        if cnt == 0 {
            break;
        }
        ans += cnt;
        s = s.iter().filter(|x| x.is_some()).copied().collect();
    }
    println!("{}", ans);
}
