AtCoder Beginner Contest 120
C
Unification
AtCoder
⌀ 372
原题
← BD →
翻译中…

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.

翻译中…

样例

Input #1
0011
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.
Input #2
11011010001011
Output #2
12
Input #3
0
Output #3
0
题目信息
题号
abc120_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。