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



Sample input:
0011


Sample output:
4

Submission status: Accepted

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n = input()
s = list(n)
r = 0
b = 0

cnt = 0
for i in s:
    if i == '0':
        if b > 0:
            b -= 1
            cnt += 2
        else:
            r += 1
    else:
        if r > 0:
            r -= 1
            cnt += 2
        else:
            b += 1
print(cnt)

Submission status: Accepted

Solution code:
strnum = input()
zero_count = strnum.count("0")
one_count = strnum.count("1")
if zero_count >= one_count:
    print(one_count*2)
else:
    print(zero_count*2)

Submission status: Accepted

Solution code:
s = input()

s = list(s)


a = s.count('0')
b = s.count('1')

print(min(a, b) * 2)

Submission status: Accepted

Solution code:
S = input()
count0 = S.count('0')
count1 = S.count('1')
min_count = min(count0, count1)
print(min_count * 2)

Submission status: Accepted

Solution code:
s = sorted(input())
zero = s.count('0')
one = s.count('1')
print(2*min(zero, one))

Submission status: Accepted

Solution code:
S = input()

x = S.count("0")
y = S.count("1")
print(min(x, y) * 2)

Submission status: Accepted

Solution code:
S=str(input())
Slist=list(S)
onecount=Slist.count("1")
zerocount=Slist.count("0")
print(2*min(zerocount,onecount))

Submission status: Accepted

Solution code:
S = input()
i = 0
n = 0
while i < len(S) - 1:
        if S[i] != S[i + 1]:
                n += 2
                S = S[:i] + S[i + 2:]
                if i > 0:
                        i -= 1
        else:
                i += 1
print(n)

Submission status: Accepted

Solution code:
s = input()
a = 0
b = 0
for e in s:
    if e == "0":
        a += 1
    else:
        b += 1

print(min(a, b) * 2)

Submission status: Accepted

Solution code:

# coding: utf-8

# In[20]:


S = list(str(input()))


# In[21]:


if S == "0" or S == "1":
    print(0)
else:
    print(min(S.count("0"),S.count("1")) * 2)

Submission status: Accepted

Solution code:
ss = input()
zero = ss.count('0')
one = ss.count('1')
print(min(zero,one)*2)

Submission status: Accepted

Solution code:
#coding:utf-8

import sys
S=map(int,raw_input())

st=[]

ans=0
for s in S:
    st.append(s)
    if len(st)>=2:
        a=st.pop()
        b=st.pop()
    else:
        continue
    if (a==0 and b==1) or (a==1 and b==0):
        ans+=2
    else:
        st.append(a);st.append(b)
print(ans)

Submission status: Accepted

Solution code:
s = input()

n_0 = s.count("0")
n_1 = s.count("1")

print(min([n_0,n_1])*2)

Submission status: Accepted

Solution code:
import collections


S = input()
N = len(S)

c = collections.Counter(S)

if len(c) == 1:
    print(0)
else:
    print(c.most_common()[-1][1]*2)

Submission status: Accepted

Solution code:
S = map(int, raw_input())
count1 = sum(S)
count0 = len(S)-count1
print 2*min(count0,count1)

Submission status: Accepted

Solution code:
def solve(s):
    num_zero = s.count("0")
    num_one = s.count("1")
    num_pair = min(num_zero, num_one)
    return num_pair * 2


def main():
    s = input()
    print(solve(s))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import collections
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()

zero = s.count("0")
one = s.count("1")

print(min(zero,one)*2)

Submission status: Accepted

Solution code:
S=list(input())
S=[int(h) for h in S]
zero=S.count(0)
one=S.count(1)
if zero > one:
    print(one*2)
else:
    print(zero*2)
#print(S)

Submission status: Accepted

Solution code:
S = input()

cnt_0 = 0
cnt_1 = 0

for s in S:
  if s == "0":
    cnt_0 += 1
  else:
    cnt_1 += 1

print(min(cnt_0, cnt_1)*2)

Submission status: Accepted

Solution code:
s = input()
from collections import Counter
c = Counter(s)
c['0'] += 0
c['1'] += 0
print(2 * min(c.values()))

Submission status: Accepted

Solution code:
s=input()
a=s.count("0")
b=s.count("1")
if a>b:
  print(2*b)
else:
  print(2*a)

Submission status: Accepted

Solution code:
S=input()
cnt0=0
cnt1=0
for i in range(len(S)):
    if S[i]=='1':
        cnt1+=1
    else:
        cnt0+=1
print(len(S)-abs(cnt0-cnt1))

Submission status: Accepted

Solution code:
from sys import stdin
input = stdin.readline

S = list(input())
a = S.count("0")
b = S.count("1")
print(2*min(a, b))

Submission status: Accepted

Solution code:
S=input()
ONE=0
ZERO=0
for i in S:
    if(i=="1"):
        ONE+=1
    else:
        ZERO+=1
print(min(ONE,ZERO)*2)

Submission status: Accepted

Solution code:
s = list(map(int, list(input())))

z = s.count(0)
o = s.count(1)
print(min(z, o) * 2)

Submission status: Accepted

Solution code:
import sys

S = input()

num1 = S.count('1')
num0 = len(S) - num1

print(min([num1, num0]) * 2)

Submission status: Accepted

Solution code:
def c_unification(S):
    stack = []
    ans = 0
    for c in S:
        if len(stack) == 0:
            stack.append(c)
        elif (stack[-1] == '0' and c == '1') or (stack[-1] == '1' and c == '0'):
            stack.pop()
            ans += 2
        else:
            stack.append(c)
    return ans

S = input()
print(c_unification(S))

Submission status: Accepted

Solution code:
S = list(input())

a = S.count('1')
b = S.count('0')

print(min(a,b)*2)

Submission status: Accepted

Solution code:
s = input()
c = sum([int(i) for i in s])
print(min(c,len(s)-c)*2)

Submission status: Accepted

Solution code:
S = input()

a, b = 0, 0

for c in S:
    if c == '0':
        a += 1
    else:
        b += 1

print(min(a, b) * 2)

Submission status: Accepted

Solution code:
s = input()
m = 0
for i in s:
    if i == '1':
        m += 1
    else:
        m -= 1
print(len(s)-abs(m))

Submission status: Accepted

Solution code:
s=input()
if s.count("0")==len(s) or s.count("1")==len(s):
    print(0)
else:
    print(min(s.count("0"),s.count("1"))*2)

Submission status: Accepted

Solution code:
s = input()

co = [0, 0]
for i in range(len(s)) :
    co[int(s[i])] += 1

print(len(s)-abs(co[0]-co[1]))

Submission status: Accepted

Solution code:
S = input()
red = 0
blue = 0
for i in S:
    if i =="0":
        red += 1
    else:
        blue += 1 
print(min(red,blue)*2)

Submission status: Accepted

Solution code:
A=input()
count=0
arr=[]
for i in A:
    if len(arr)==0:
        arr.append(i)
    else:
        if i != arr[-1]:
            del arr[-1]
            #arr.remove(-1)
            count+=2
        else:
            arr.append(i)
print(count)

Submission status: Accepted

Solution code:
s = input()
zero_cnt = s.count('0')
one_cnt = s.count('1')
print(min(zero_cnt,one_cnt)*2)

Submission status: Accepted

Solution code:
s=input()
zero=s.count("0")
one=s.count("1")
print(min(zero,one)*2)

Submission status: Accepted

Solution code:
S = input()
print(len(S) - abs(sum(1 for s in S if s == '0') - sum(1 for s in S if s == '1')))

Submission status: Accepted

Solution code:
s = input()
remain_str = ''
count = 0
for i in s:
    if len(remain_str) == 0:
        remain_str += i
    elif (i == '0' and remain_str[-1] == '1') or (i == '1' and remain_str[-1] == '0'):
        count += 2
        remain_str = remain_str[:-1]
    else:
        remain_str += i
print(count)

Submission status: Accepted

Solution code:
a = list(map(str, input()))

c0 = a.count("0")
c1 = a.count("1")

print(min(c0,c1)*2)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline
s = input()
red = 0
blue = 0
for i in s[:-1]:
    if i == '0':
        red += 1
    else:
        blue += 1
print(int(min(red, blue)*2))

Submission status: Accepted

Solution code:
t = input()

count = 0
t2 = ""
for c in t:
    t2 += c
    while t2.endswith("01") or t2.endswith("10"):
        t2 = t2[:-2]
        count += 2
print(count)

Submission status: Accepted

Solution code:
s=input()
r=s.count("0")
b=s.count("1")
print(min(r,b)*2)

Submission status: Accepted

Solution code:
s=input()
count0=s.count('0')
count1=s.count('1')

sa=abs(count0-count1)

print(len(s)-sa)

Submission status: Accepted

Solution code:
S = input()

n1 = len([i for i in S if i == '1'])
n0 = len(S) - n1
print(min(n1, n0) * 2)

Submission status: Accepted

Solution code:
S = [int(x) for x in input()]

R = S.count(0)
B = S.count(1)

print(min(R,B) * 2)

Submission status: Accepted

Solution code:
S = input()
red = S.count("0")
blue = S.count("1")
print(min(red,blue)*2)

Submission status: Accepted

Solution code:
S = input()

zero = 0
one = 0

for i in range(len(S)):
	if S[i]=='0':
		zero += 1
	else:
		one += 1
print(2*min(zero,one))

Submission status: Accepted

Solution code:
S = input()
print(2 * min(S.count("0"),S.count("1")))

Submission status: Accepted

Solution code:
N=input()
#print(N)

A=N.count("0")
B=N.count("1")
print(len(N)-abs(A-B))

Submission status: Accepted

Solution code:
s = list(input())
num_0 = s.count('0')
num_1 = s.count('1')
print(min(num_0, num_1) * 2)

Submission status: Accepted

Solution code:
# -*- coding utf-8 -*-

S = input()

stack = []

ans = 0
for s in S:
    if len(stack) == 0 or stack[-1] == s:
        stack.append(s)
    else:
        stack.pop()
        ans += 2

print(ans)

Submission status: Accepted

Solution code:
s = input()
ans = s.count("0")
print(min(ans, len(s)-ans)*2)

Submission status: Accepted

Solution code:
s=input()
n=len(s)
r=0
b=0
for i in range(n):
  if s[i]=='0':
    r+=1
  else:
    b+=1
ans=min(r,b)
print(2*ans)

Submission status: Accepted

Solution code:
s = input()
zero = s.count('0')
one = s.count('1')
print(len(s)-(abs(zero-one)))

Submission status: Accepted

Solution code:
#coding:utf-8
s = input()
print(min(s.count('0'),s.count("1"))*2)

Submission status: Accepted

Solution code:
s = input()
x = 0
y = 0
cnt = 0
for c in s:
    if c == '0':
        if y > 0:
            y -= 1
            cnt += 2
        else:
            x += 1
    else:
        if x >0:
            x -= 1
            cnt += 2
        else:
            y += 1
print(cnt)

Submission status: Accepted

Solution code:
S = input()
a = S.count("0")
b = S.count("1")
c = min(a,b)
print(2*c)

Submission status: Accepted

Solution code:
S = input()

N = len(S)
cnt = 0
cntb = 0
for i in S:
    if i == '0':
        cnt += 1
    elif i == '1':
        cntb += 1

print(2*min(cnt,cntb))

Submission status: Accepted

Solution code:
def solve():
  S = input()
  r = S.count('0')
  b = len(S) - r
  return min(r, b) * 2

print(solve())

Submission status: Accepted

Solution code:
s = input()
one = s.count("1")
zero = s.count("0")
print(min(one, zero)*2)

Submission status: Accepted

Solution code:
S=input()

num0=S.count('0')
num1=S.count('1')

print(min(num0*2,num1*2))

Submission status: Accepted

Solution code:
s = list(input())

a = s.count('0')

print(min(a, len(s) - a) * 2)

Submission status: Accepted

Solution code:
s = list(map(int, input()))
print(min(len(s)-sum(s), sum(s))*2)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = input()

c0 = s.count('0')
c1 = s.count('1')

remove = min(c0, c1)
print(remove * 2)

Submission status: Accepted

Solution code:
S = input()

a = S.count("0")
b = S.count("1")
print(min(a,b)*2)

Submission status: Accepted

Solution code:
listS = list(str(input()))
n = len(listS)

bef=-1
flag=1
while flag:
    index = 0
    flag=0
    while index < len(listS):
        if index==0:
            bef=listS[index]
            index+=1
        else:
            if bef != listS[index]:
                flag=1
                del listS[index]
                del listS[index-1]
                index = index-1
            else:
                bef = listS[index]
                index+=1
print(n-len(listS))

Submission status: Accepted

Solution code:
s = input()
c0 = 0
c1 = 0
for i in s:
    if i == "0":
        c0 += 1
    else:
        c1 += 1
print(min(c1, c0)*2)

Submission status: Accepted

Solution code:
s = input()
zero = s.count('0')
one = len(s) - zero

print(min(zero,one) * 2)

Submission status: Accepted

Solution code:
S=input()
print(min(S.count('0')*2,S.count('1')*2))

Submission status: Accepted

Solution code:

S = input()
a = S.count('0')
b = S.count('1')

ans = min(a, b) * 2

print(ans)

Submission status: Accepted

Solution code:
s = input()
a = 0
b = 0
for i in s:
    if i == '0':
        a += 1
    else:
        b += 1

print(min(a,b)*2)

Submission status: Accepted

Solution code:
S = input()
red = 0
blue = 0

for s in S:
    if s == '0':
        red += 1
    else:
        blue += 1
print(min(red,blue)*2)

Submission status: Accepted

Solution code:
S=str(input())
N=len(S)
zero=0
one=0
for i in range(0,N):
    if(S[i]=="0"):
        zero+=1
    else:
        one+=1
ans=min(zero,one)
print(ans*2)

Submission status: Accepted

Solution code:
bs = list(input())
h = {}
h['1'] = 0
h['0'] = 0
for b in bs:
  h[b] += 1
print(min([h['1'], h['0']]) * 2)

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import bisect
from datetime import datetime as dt

S = raw_input()
print min(S.count('1'), S.count('0')) * 2

Submission status: Accepted

Solution code:
S = input()
z = S.count('0')
o = len(S) - z
print(len(S) - abs(z-o))

Submission status: Accepted

Solution code:
S = input()
stack = []
top = None
ans = 0
for c in S:
  if top and c != top:
    ans += 2
    stack.pop()
    top = None if len(stack) == 0 else stack[-1]
  else:
    stack.append(c)
    top = c
print(ans)

Submission status: Accepted

Solution code:
s = str(input())
n = len(s)
a = 0
b = 0
for i in range(n):
  if s[i] == "0":
    a += 1
  else:
    b += 1
print(2*min(a,b))

Submission status: Accepted

Solution code:
s=input()
ls=len(s)
sz=0
so=0

for i in range(ls):
    if s[i]=="0":
        sz+=1
    else:
        so+=1

print(min(so,sz)*2)

Submission status: Accepted

Solution code:
s = input().rstrip()
n = s.count('0')
m = s.count('1')
print(2 * min(n, m))

Submission status: Accepted

Solution code:
S = input()

red = 0
blue = 0
ans = 0
for s in S:
    if s == "0":
        red += 1
        if blue >= 1:
            ans += 2
            red -=1
            blue -= 1
    else:
        blue += 1
        if red >= 1:
            red -= 1
            blue -=1
            ans += 2

print(ans)

Submission status: Accepted

Solution code:
""" AtCoder """

S = input()

print(2*min(S.count('0'), S.count('1')))

Submission status: Accepted

Solution code:
S = input()
num0=S.count('0')
num1=S.count('1')
print(min(num0,num1)*2)

Submission status: Accepted

Solution code:
S = input()

print(min(2*S.count("0"),2*S.count("1")))

Submission status: Accepted

Solution code:
s = list(input())

r = s.count('0')
b = s.count('1')

print(min(r,b)*2)

Submission status: Accepted

Solution code:
S = input()
N = len(S)
red = 0
blue = 0

for i in range(N):
    if S[i] == '0':
        red += 1
    else:
        blue += 1

print(2 * min(red, blue))

Submission status: Accepted

Solution code:
S = input()
c0 = 0
c1 = 0
for i in range(len(S)):
    if S[i] == '0':
        c0 += 1
    else:
        c1 += 1
print(min(c0, c1) * 2)

Submission status: Accepted

Solution code:
s=list(input())
z=0
for i in range(len(s)):
    if s[i]=="0":
        z+=1
o=len(s)-z
print(min(z,o)*2)

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("GREATER")
    elif (x<y): print("LESS")
    else: print("EQUAL")

def ip():
    return int(input())


#n = ip()                              #入力整数1つ
#n,m= (int(i) for i in input().split())      #入力整数横2つ
#a,b,k = (int(i) for i in input().split())    #入力整数横3つ
#n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(h)]
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
b = []
red = 0
blue = 0
for i in range(len(a)):
    if a[i] == '0':
        red+=1
        b.append(0)
    else:
        blue+=1
        b.append(1)
print(min(red,blue)*2)

Submission status: Accepted

Solution code:
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

S = input()

N = len(S)
C = Counter(S[:-1]+'01')
a, b = C.values()
print((min(a, b)-1)*2)

Submission status: Accepted

Solution code:
S = input()
k = 0
ans = 0
for s in S:
    if s == '1':
        if k <= -1:
            ans += 2
        k += 1
    else:
        if k >= 1:
            ans += 2
        k -= 1
print(ans)

Submission status: Accepted

Solution code:
a = input()
print(min(a.count("0"), a.count("1")) * 2)

Submission status: Accepted

Solution code:
s = input()
a = s.count("0")
b = s.count("1")
if a > b :
    print(b*2)
else :
    print(a*2)

Submission status: Accepted

Solution code:
S = str(input())


ones = S.count('1')
zeros = S.count('0')
print(min(ones, zeros)*2)

Submission status: Accepted

Solution code:
S = input()
N = len(S)
red = S.count('0')
blue = S.count('1')
print(2 * min(red, blue))

Submission status: Accepted

Solution code:
s=input()
zero=0
one=0
for i in range(len(s)):
  if s[i]=='0':
    zero+=1
  else:
    one+=1
print(len(s)-abs(one-zero))

Submission status: Accepted

Solution code:
S = input()
c0 = 0
c1 = 0
for i in range(len(S)):
    if S[i] == '0':
        c0 += 1
    else:
        c1 += 1
print(2 * min(c0, c1))

Submission status: Accepted

Solution code:
s=input()
c0=len([1 for i in s if i=='0'])
c1=len([1 for i in s if i=='1'])
print(2*min(c0,c1))

Submission status: Accepted

Solution code:
S = input()
r = S.count('0')
b = S.count('1')
print(min(r,b)*2)

Submission status: Accepted

Solution code:
s = input().strip()
n = len(s)
n0 = len([0 for c in s if c == '0'])
n1 = n - n0
print(2 * min(n0, n1))

Submission status: Accepted

Solution code:
N = input()

zero = len([i for i in N if i == "0"])
one = len([i for i in N if i == "1"])

print(min(zero,one)*2)

Submission status: Accepted

Solution code:
from collections import Counter
S = input()
c = Counter(S)
cnt = c.values()
print(min(cnt)*2 if len(cnt) == 2 else 0)

Submission status: Accepted

Solution code:
a = input()

count=0
for i in a:
    count+=int(i)

print(2*(min(len(a)-count,count)))

Submission status: Accepted

Solution code:
s = input()
o = 0
z = 0
for i in s:
    if i == "0":
        z += 1
    else:
        o += 1
print(min(z, o) * 2)

Submission status: Accepted

Solution code:
s = input()
count_1 = 0
count_0 = 0
ans = 0
for i in range(len(s)):
    if s[i] == "1":
        if count_0:
            ans += 2
            count_0 -= 1
        else:
            count_1 += 1
    else:
        if count_1:
            ans += 2
            count_1 -= 1
        else:
            count_0 += 1
print(ans)

Submission status: Accepted

Solution code:
import sys


fin = sys.stdin.readline
S = fin()[:-1]

stack = []

for color in S:
    if not stack or stack[-1] == color:
        stack.append(color)
    else:
        stack.pop()

print(len(S) - len(stack))

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc120/tasks/abc120_c

import itertools
import collections
import bisect

def main():
    S = list(input())
    zero_n = S.count("0")
    one_n = S.count("1")
    print(min(zero_n, one_n) * 2)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
print(len(s) - abs(s.count("0")-s.count("1")))

Submission status: Accepted

Solution code:
s = list(input())

#print(s.count('0'))

if len(s) == 1:
    print(0)
    exit(0)

if s.count('0') == s.count('1'):
    print(len(s))

else:
    n = abs(s.count('0') - s.count('1'))
    print(len(s) - n)

Submission status: Accepted

Solution code:
s = input()

zeros = 0
ones = 0

for x in s:
    if x == '0':
        zeros += 1
    else:
        ones += 1

print(min(zeros, ones)*2)

Submission status: Accepted

Solution code:
s = str(input())
zero = s.count("0")
one = s.count("1")
print(min(zero, one)*2)

Submission status: Accepted

Solution code:
S=input()
a=0
b=0
for s in S:
    if s=='0':
        a+=1
    else:
        b+=1
print(2*min(a,b))

Submission status: Accepted

Solution code:
s = input()
r = s.count("0")
b = s.count("1")
print(min(r, b)*2)

Submission status: Accepted

Solution code:
S = input()

r = sum([True for x in S if x == '0'])
b = len(S) - r

print(min(r,b)*2)

Submission status: Accepted

Solution code:
S = input()

count_red = 0
count_blue = 0

for s in S:
    if s == "0":
        count_red += 1
    else:
        count_blue += 1

print(2 * min(count_red, count_blue))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import Counter
C = Counter(input())
print(min(C["0"], C["1"])*2)

Submission status: Accepted

Solution code:
s = list(input())

num_0 = s.count('0')
num_1 = s.count('1')

pick_num = min(num_0,num_1)
cnt = pick_num*2
print(cnt)

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
from collections import deque

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


s = SI()

ans = 0
q = deque()
for c in s:
    if not q:
        q.append(c)
        continue
    if q[-1] != c:
        ans += 1
        q.popleft()
        continue
    q.append(c)

print(ans * 2)

Submission status: Accepted

Solution code:
s = input()
t = []
ans = 0
for i in range(len(s)):
    t += [s[i]]
    if t[-2:] == ["0", "1"] or t[-2:] == ["1", "0"]:
        t.pop()
        t.pop()
        ans += 2

print(ans)

Submission status: Accepted

Solution code:
s=input()
ct0=0;ct1=0
for i in range(len(s)):
  if s[i]=='0':ct0+=1
  else:ct1+=1
print(min(ct0,ct1)*2)

Submission status: Accepted

Solution code:
s = input()
_0 = s.count('0')
_1 = s.count('1')
print(min(_0, _1) * 2)

Submission status: Accepted

Solution code:
S=input()
red=S.count("0")
blue=S.count("1")

if red==0 or blue==0:
    print(0)
else:
    print(min(red,blue)*2)

Submission status: Accepted

Solution code:
s = input()
que = []
ans = 0
for i in range(len(s)):
  if que == []:
    que.append(s[i])
  else:
    if que[-1] != s[i]:
      ans += 2
      que.pop()
    else:
      que.append(s[i])
print(ans)

Submission status: Accepted

Solution code:
Ss = input()

num0 = Ss.count('0')
num1 = len(Ss) - num0

print(min(num0, num1) * 2)

Submission status: Accepted

Solution code:
# 0 = 青　1 = 赤
s = list(input())
if len(s) == 1:
    print(0)
    exit()

tmp1 = s.count('1')
tmp2 = s.count('0')
if tmp1 == 0 or tmp2 == 0:
    print(0)
else:
    print(min(tmp1, tmp2) * 2)

Submission status: Accepted

Solution code:
STR = input();
num_zero=0;
num_one=0;

for i in STR:
    if(i=="0"):
        num_zero+=1;
    else:
        num_one+=1;

print(min(num_zero, num_one) *2);

Submission status: Accepted

Solution code:
S = input()
d = []
num = 0
for i in range(len(S)):
    if len(d) == 0 or (len(d) > 0 and d[-1] == S[i]):
        d.append(S[i])
    else:
        d.pop(-1)
        num += 2

print(num)

Submission status: Accepted

Solution code:
S = input().strip()

stack = []
dc = 0
for s in S:
  if len(stack) == 0:
    stack.append(s)
  elif s == '0' and stack[-1] == '1':
    stack.pop()
    dc += 2
  elif s == '1' and stack[-1] == '0':
    stack.pop()
    dc += 2
  else:
    stack.append(s)
print(dc)

Submission status: Accepted

Solution code:
s = input()
z = 0
o = 0
for i in s:
    if i == "0":
        z += 1
    else:
        o += 1
print(2*min(o,z))

Submission status: Accepted

Solution code:
s=input()
red=s.count('0')
blue=s.count('1')
print(2*min(red,blue))

Submission status: Accepted

Solution code:
S = list(input())

a = 0
b = 0
for i in S:
  if i == "0":
    a += 1
  else:
    b += 1

print(min(a, b) * 2)

Submission status: Accepted

Solution code:
S = input()
num_1 = 0
num_0 = 0

for s in S:
    if s == '1':
        num_1 += 1
    else:
        num_0 += 1

print(2*min(num_1, num_0))

Submission status: Accepted

Solution code:
S=input()

print(2*min(S.count("0"),S.count("1")))

Submission status: Accepted

Solution code:
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

S = raw_input()
cnt1 = cnt2 = 0
for c in S:
    if c == '0':
        cnt1 += 1
    else:
        cnt2 += 1

print min(cnt1, cnt2) * 2

exit()

A, B, K = map(int, raw_input().split())

cnt = 0

for i in range(1, 200):
    if A % i == 0 and B % i == 0:
        cnt += 1
    if cnt == K:
        print i
        exit()

Submission status: Accepted

Solution code:
s = input()
a = s.count('0')
b = s.count('1')
print(min(a,b)*2)

Submission status: Accepted

Solution code:
S = input()
st = []
ans = 0
for c in S:
    if st and st[0] != c:
        st.pop()
        ans += 2
    else:
        st.append(c)
print(ans)

Submission status: Accepted

Solution code:
S = list(input())
N = len(S)
c0 = 0
c1 = 0

for i in S:
	if i == "0":
		c0 += 1
	else:
		c1 += 1

if c0 >= c1:
	print(N - c0 + c1)
else:
	print(N - c1 + c0)

Submission status: Accepted

Solution code:
s = input()
a = 0
b = 0
for i in s:
    if i == "1":
        a += 1
    else:
        b += 1
print(len(s)-abs(a-b))

Submission status: Accepted

Solution code:
s = input()
c0, c1 = 0, 0
for c in s:
  if c == '0':
    c0 += 1
  else:
    c1 += 1
print(min(c0, c1) * 2)

Submission status: Accepted

Solution code:
S = input()
zero = S.count('0')
one = S.count('1')

print(min(zero, one) << 1)

Submission status: Accepted

Solution code:
S = raw_input()
T = []
for s in S:
  if len(T)>0 and T[-1]!=s:
    T.pop()
  else:
    T += [s]
print len(S)-len(T)

Submission status: Accepted

Solution code:
v = input()
l = len(v)
a = 0
b = 0
for c in v:
    if c == '0':
        a += 1
    else:
        b += 1
print(2 * min(a, b))

Submission status: Accepted

Solution code:
S=input()
from collections import deque
QUE=deque()

for s in S:
    QUE.append(s)

    while len(QUE)>=2 and  QUE[-1]!=QUE[-2]:
        QUE.pop()
        QUE.pop()

print(len(S)-len(QUE))

Submission status: Accepted

Solution code:
# N,M = map(int, input().split())
S = input()
from collections import Counter
c = Counter(S)
# print(c)
print(min(c["0"], c["1"])*2)

Submission status: Accepted

Solution code:
a = input()
print(min(a.count('1'), a.count('0')) * 2)

Submission status: Accepted

Solution code:
def inpl():
    return list(map(int, input().split()))


S = input()
print(min(S.count('0'), S.count('1')) * 2)

Submission status: Accepted

Solution code:
from collections import Counter
s = str(input())
print(len(s)-abs(s.count("1")-s.count("0")))

Submission status: Runtime Error

Solution code:
import sys

cubes = list(input()) # 入力受付
stack = []
count = 0

for cube in cubes:
    print(stack, cube)
    if not stack:
        stack.append(cube)
    elif stack[-1] != cube:
        print(stack, cube)
        count += 2
        stack.pop()
    else:
        stack.append(cube)
print(count)

Submission status: Runtime Error

Solution code:
import sys
import re
def INPUT_AS_INT(): return int(sys.stdin.readline().rstrip())
# def INPUT_AS_INT_LIST(): return list(map(int,sys.stdin.readline().rstrip().split()))
# def INPUT_AS_STRING(): return sys.stdin.readline().rstrip()
# def INPUT_AS_STRING_LIST(): return list(sys.stdin.readline().rstrip().split())

str = INPUT_AS_STRING() # 入力受付
_str = str #　結果と比較用
while True:
    tmp = str
    tmp = re.sub("10", "", tmp)
    tmp = re.sub("01", "", tmp)
    if str == tmp:
        break
    str = tmp

print(len(_str) - len(str))

Submission status: Runtime Error

Solution code:
s=input()
c=s.count("1")
print(2*(min(c,n-c)))

Submission status: Runtime Error

Solution code:
S = str(input())
i, ans = 0, 0
if len(S) <= 1:
    print(0)
    exit()

while i < abs(len(S)-S.count("1")):
    if S[i] != S[i+1]:
        S = S[:i]+S[i+2:]
        i = -1
        ans += 2
    i += 1
print(ans)

Submission status: Runtime Error

Solution code:
S=input()
List = list(S)
zeroNum = List.count("0")
oneNum = List.count("1")
res = min(reroNum,oneNum)
print(res*2)

Submission status: Runtime Error

Solution code:
def next_check(cubes):
	index_list = []
	for cube_index in reversed(range(1, len(cubes))):
		if ((cube_index not in index_list) and (cubes[cube_index] == cubes[cube_index - 1])):
			index_list.append(cube_index - 1)
			index_list.append(cube_index)
	l = len(index_list)
	for i in reversed(index_list):
		cubes.pop(i)
	return (cubes, l)

def main():
	cubes = input()
	for c in cubes:
		if c not in ['0', '1']:
			exit(0)
	cube_list = []
	for cube in cubes:
		cube_list.append(cube)
	l = len(cube_list)
	k = 0
	while (l != 0):
		cubes, l = next_check(cube_list)
		k += l
	print(k)

if __name__ == "__main__":
	main()

Submission status: Runtime Error

Solution code:
def next_check(cubes):
	index_list = []
	for cube_index in range(1, len(cubes)):
		if cube_index not in index_list and cubes[cube_index] == cubes[cube_index - 1]:
			index_list.append(cube_index - 1)
			index_list.append(cube_index)
	l = len(index_list)
	for i in reversed(index_list):
		cubes.pop(i)
	return (cubes, l)


cubes = input()
for c in cubes:
	if c not in ['0', '1']:
		exit(0)
cube_list = []
for cube in cubes:
	cube_list.append(cube)
l = len(cube_list)
k = 0
while (l != 0):
	cubes, l = next_check(cube_list)
	k += l
print(k)

Submission status: Runtime Error

Solution code:
def next_check(cubes):
	index_list = []
	for cube_index in range(1, len(cubes)):
		if cube_index not in index_list and cubes[cube_index] == cubes[cube_index - 1]:
			index_list.append(cube_index - 1)
			index_list.append(cube_index)
	l = len(index_list)
	for i in reversed(index_list):
		cubes.pop(i)
	return (cubes, l)


cubes = input()
for c in cubes:
	if c not in ['0', '1']:
		exit(0)
cube_list = []
for cube in cubes:
	cube_list.append(cube)
l = len(cube_list)
k = 0
while (l != 0):
	cubes, l = next_check(cube_list)
	k += l
print(k)