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 (GCC 9.2.1) (judge verdict: Accepted)

/* ex9_1
   Graku */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct node {
    struct node *next;
    char binary;
}node;

int get_last(node *l);
node* pop(node *l);
node* push(node *l, char n);

int main() {
    node *list = NULL;
    int count = 0;
    char s[100000];
    scanf("%s", s);

    for (int i = 0; i < strlen(s); i++) {
        if (list == NULL) { //list is empty
            list = push(list, s[i]);
        }
        else if (list->binary != s[i]) {
            list = pop(list);
            count += 2;
        }
        else {
            list = push(list, s[i]);
        }
    }

    printf("%d\n", count);
    return 0;
}

node* pop(node *list) {
    if (list == NULL) { //list is empty
        printf("Error: list is NULL\n");
        exit(1);
    }
    if (list->next == NULL) { //list has one element
        return NULL; //list is empty
    }
    node *head = list->next;
    free(list);
    return head;
}

node* push(node *list, char c) {
    node *new = malloc(sizeof(node)); //new element
    new->next = list; //new is end of list
    new->binary = c;
    return new;
}