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 C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long mod = 1e9 + 7;


const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


//最大公約数
int gcd( int m, int n ) {
  // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) )
    return 0;
  // ユークリッドの方法
  while ( m != n ) {
    if ( m > n ) m = m - n;
    else         n = n - m;
  }
  return m;
}//gcd


//最小公倍数
int lcm( int m, int n ) { // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) )
    return 0;
  return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm




int main() {

  string s;

  cin >> s;
  long n = s.size();



  long ans = 0;
  vector<char> s1;
  for (int i = 0; i < n; ++i) {
    s1.push_back(s[i]);
  }



  long bef = s1[0] - '0';
  while (true) {
    vector<char> s2;
    for (int i = 0; i < s1.size()-1; ++i) {
      if (bef != s1[i + 1] - '0') {
        ans += 2;
        i++;
      } else {
        s2.push_back(s[i]);
        if (i==n-2)s2.push_back(s[i + 1]);
      }
    }


    for(auto v : s2){
      cerr << v;
    }cerr <<endl;


    if (s1.size() == s2.size() || s2.size() == 0){
      break;
    }else{
      s1.clear();
      for (int i = 0; i < s2.size(); ++i){
        s1.push_back(s2[i]);
      }
    }



  }



  cout <<ans;
  // cout << ((ans)?  "TBD" : "Heisei" );



}