Problem:
Score : 300 points

Problem Statement

There are N cubes stacked vertically on a desk.

You are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.

You can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.

At most how many cubes can be removed?

Constraints

1 \leq N \leq 10^5

|S| = N

Each character in S is 0 or 1.

Input

Input is given from Standard Input in the following format:

S

Output

Print the maximum number of cubes that can be removed.

Sample Input 1

0011

Sample Output 1

4

All four cubes can be removed, by performing the operation as follows:

Remove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.

Remove the first and second cubes from the bottom.

Sample Input 2

11011010001011

Sample Output 2

12

Sample Input 3

0

Sample Output 3

0

Solution in Rust (1.42.0) (judge verdict: Accepted)

#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]
 
use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;
 
use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;

    input!{
        s: Chars,
    }
    // let mut s: VecDeque<char> = VecDeque::from(s);
    // let mut leaved = vec![];
    // let all_num = s.len();

    // loop {
    //     // dbg!(&s);
    //     // dbg!(&leaved);
    //     if (s.len() == 0 && (leaved.iter().all_equal() || leaved.len() == 0)) || s.iter().chain(leaved.iter()).all_equal() { break; }

    //     let s1 = s.pop_front().unwrap();

    //     if !leaved.is_empty() {
    //         let l = leaved.pop().unwrap();
    //         if l != s1 { continue; }
    //         leaved.push(l);
    //     }

    //     let s2 = s.pop_front().unwrap();

    //     if s1 != s2 { continue };

    //     leaved.push(s1);
    //     s.push_front(s2);
    // }

    // println!("{}", all_num - s.len() - leaved.len())

    let mut r = 0;
    let mut b = 0;
    
    for &c in s.iter() {
        if c == '0' { r += 1 } else { b += 1 }
    }

    println!("{}", std::cmp::min(r, b) * 2)
}

fn main() {
    solve();
}