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:
S = input()
ans = 2*min(S.count("0"), S.count("1"))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L=list(input())
cnt=0
x=[]
import queue
q=queue.Queue()

for l in L:q.put(l)
while not q.empty():
    x.append(q.get())
    if len(x)>1:
        if x[-2:].count("0")==1:
            x.pop(-2)
            x.pop(-1)
            cnt+=2
print(cnt)

Submission status: Accepted

Solution code:
S = input()

n0 = S.count("0")
n1 = S.count("1")

print(len(S) - abs(n1 - n0))

Submission status: Accepted

Solution code:
s = list(input())
blue = s.count('0')
red = s.count('1')
print(len(s)-abs(red-blue))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# AtCoder
S = input()

stack = []
count = 0
for e in S:
    if not stack:
        stack.append(e)
    elif stack[-1] != e:
        stack.pop(-1)
        count += 2
    else:
        stack.append(e)

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(map(int,input()))
count_0 = S.count(0)
count_1 = len(S)-count_0
print(min(count_0,count_1)*2)

Submission status: Accepted

Solution code:
from sys import stdin

s = stdin.readline().rstrip()

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

print(min(a,b)*2)

Submission status: Accepted

Solution code:
a = input()
s = [int(i) for i in a]
count = 0
ans = 0
while True:
    if (len(s) == count+1) or len(s) == 0:
        break
    if (s[count] == 0 and s[count+1] == 1) or (s[count] == 1 and s[count+1] == 0):
        ans += 1
        s.pop(count)
        s.pop(count)
        if count != 0:
            count -= 1
    else:
        count += 1
print(ans*2)

Submission status: Accepted

Solution code:
s_L = [int(val) for val in input()]
n = len(s_L)

if sum(s_L) == 0 or sum(s_L) == n:
    print(0)
    exit()
elif n == 1:
    print(0)
    exit()

one = s_L.count(1)
zero = s_L.count(0)
print(2*min(zero,one))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())

N = len(S)
i = 0
while i < len(S) - 1:
    if S[i] != S[i+1]:
        del S[i:i+2]
        if i > 0:
            i -= 1
    else:
        i += 1
print(N - len(S))

Submission status: Accepted

Solution code:
S = input()
stack_0 = []
stack_1 = []
cnt = 0
for s in S:
    if s == '0':
        if stack_1:
            cnt += 1
            stack_1.pop()
        else:
            stack_0.append('0')
    else:
        if stack_0:
            cnt += 1
            stack_0.pop()
        else:
            stack_1.append('1')

print(cnt*2)

Submission status: Accepted

Solution code:
S = input()

zero_count = S.count('0')
one_count = S.count('1')
if zero_count < one_count:
    print(zero_count*2)
else:
    print(one_count*2)

Submission status: Accepted

Solution code:
def main(s):
    a = s.count("0")
    b = s.count("1")
    return 2*min(a,b)

s = input()


print(main(s))

Submission status: Accepted

Solution code:
S = input()
# print(S)
stack = []
ans = 0
for c in S:
    if stack and stack[0] != c:
#         print("stack={}, c={} pop!".format(stack, c))
        stack.pop()
        ans += 2
    else:
#         print("stack={}, c={} append!".format(stack, c))
        stack.append(c)
#     print("c={0}, st={1}".format(c, stack))
print(ans)

Submission status: Accepted

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

zero_number = S.count('0')
one_number = S.count('1')

print(min(zero_number, one_number) * 2)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = input()
stack = []
count = 0
for s in S:
    if not stack:
        stack.append(s)
    elif stack[-1]!=s:
        stack.pop()
        count+=2
    else:
        stack.append(s)
print(count)

Submission status: Accepted

Solution code:
N = input().strip()
#print(N)
length = len(N)
#print(length)
totalZeros = 0
totalOnes = 0
for i in N:
    if i == '0':
        totalZeros += 1
    else:
        totalOnes += 1
if totalOnes < totalZeros:
    answer = totalOnes * 2
else:
    answer = totalZeros * 2

print(answer)

Submission status: Accepted

Solution code:
# ABC120 C - Unification
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

S = si()

cnt_0 = S.count('0')
cnt_1 = S.count('1')

if cnt_0 == len(S) or cnt_1 == len(S):
    print(0)
    exit()

if cnt_0 >= cnt_1:
    print(cnt_1*2)
else:
    print(cnt_0*2)

Submission status: Accepted

Solution code:
S = str(input())
W = []

for s in S:
    W.append(s)

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

dif = abs(r-b)
ans = len(W)-dif
print(ans)

Submission status: Accepted

Solution code:
S = input()

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

print(2*min(num0,num1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
l = len(S)
cnt = 0
for s in S:
    cnt += (s=='0')
print(2*min(cnt, l-cnt))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

A = S.count("0")
B = S.count("1")

less = min(A,B)

print(less * 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    S = input()
    N = len(S)
    count = 0
    list_ = []
    for i in range(len(S)):
        if len(list_) == 0:
            list_.append(S[i])
        else:
            if S[i] != list_[-1]:
                count += 2
                list_.pop(-1)
            else:
                list_.append(S[i])
    print(count)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s=list(input())
r=b=ans=0
for i in range(len(s)):
    if b==0 and s[i]=="0":
        r+=1
    elif r==0 and s[i]=="1":
        b+=1
    elif b>0 and s[i]=="0":
        b-=1
        ans+=2
    elif r>0 and s[i]=="1" :
        r-=1
        ans+=2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())

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

Submission status: Accepted

Solution code:
S = input()
stack = []
counter = 0

for s in S:
  if not stack:
    stack.append(s)
  elif stack[-1] != s:
    stack.pop()
    counter += 2
  else:
    stack.append(s)
      
print(counter)

Submission status: Accepted

Solution code:
# ABC120C - Unification
def main():
    S = input().rstrip()
    ans = min(S.count("0"), S.count("1")) * 2
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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


main()

Submission status: Accepted

Solution code:
S = input()

stack = []
ans = 0
for s in S:
    stack.append(s)
    if len(stack) >= 2 and stack[-1] != stack[-2]:
        stack.pop(-1)
        stack.pop(-1)
        ans += 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(input())
zan=[]
delete_pair=0
for i in range(len(s)):
    if zan==[]: #自分が先頭の時
        zan.append(i)
        #print(zan)
        continue
    if s[i]!=s[zan[-1]]:
        delete_pair+=1
        del zan[-1]
    else:
        zan.append(i)
    #print(zan)
print(delete_pair*2)

Submission status: Accepted

Solution code:
S=input()
r=0;b=0
for c in S:
    if c=='0':
        r+=1
    if c=='1':
        b+=1
print(len(S)-abs(r-b))

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
class Stack(object):
    def __init__(self):
        self.container = []

    def __len__(self):
        return len(self.container)

    def push(self, elem):
        self.container.append(elem)

    def pop(self):
        index = len(self.container) - 1
        if index < 0:
            return None
        ret = self.container[index]
        del self.container[-1]
        return ret

    def compare(self, val):
        return self.container[-1] == val

if __name__ == '__main__':
    string = [int(i) for i in input()]
    ret = 0
    stack = Stack()
    stack.push(string[0])
    for s in string[1:]:
        if stack.__len__() == 0:
            stack.push(s)
            continue
        if stack.compare(s):
            stack.push(s)
        else:
            ret += 2
            stack.pop()

    print(ret)

Submission status: Accepted

Solution code:
s = list(input())

# Note: init
# cnt = 0
# i = 1
#
# while i < len(s):
#     while len(s) != 0 and s[i - 1] != s[i]:
#         s.pop(i)
#         s.pop(i - 1)
#         i -= 1
#         cnt += 2
#     i += 1
#
# print(cnt)


cnt = min(s.count("0"), s.count("1"))
print(cnt*2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s  = input()

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

print(2*min(zero,one))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
stack=[]
ans=0
for s in S:
  if not stack:
    stack.append(s)
  elif stack[-1]!=s:
    stack.pop()
    ans+=2
  else:
    stack.append(s)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
i = 0
cnt = 0
while i < len(S):
    #print(S)
    if "".join(S[i:i+2]) == "01" or "".join(S[i : i + 2]) == "10":
        if i + 1< len(S):
            S.pop(i + 1)
        S.pop(i)
        cnt += 2
        i = max(0 , i - 1)
    else:
        i += 1
print(cnt)

Submission status: Accepted

Solution code:
from sys import stdin

S = stdin.readline()

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

Submission status: Accepted

Solution code:
N = raw_input()
S = [] 
for i in range(0,len(N)):
  S.append(int(N[i]))
i = len(S)-2
ans = abs(S.count(1)-S.count(0))
print len(N)-ans

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math


def func():
    str = input()
    one = str.count('1')
    zero = str.count('0')
    print(min(one, zero)*2)


if __name__ == "__main__":
    func()

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    s = str(input().rstrip('\n'))
    o = 0
    f = 0
    for i in range(len(s)):
        if s[i] == "0":
            o += 1
        else:
            f += 1
    print(min(o, f) * 2)


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
s = list(input())
l = []
cnt = 0
for i in s:
    if not l:
        l.append(i)
    else:
        if l[-1] != i:
            l.pop()
            cnt += 2
        else:
            l.append(i)
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(map(int,input()))
if  1  not in s or 0 not in s:
    print(0)
    exit()
print(2*min(s.count(0),s.count(1)))

Submission status: Accepted

Solution code:
s = input()
s = [int(s[i]) for i in range(len(s))]
print(len(s) - abs(s.count(0)-s.count(1)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=input()
O=0
I=0
for i in N :
    if int(i) == 0 :
        O+=1
    else:
        I+=1
print(len(N)-abs(I-O))

Submission status: Accepted

Solution code:
from collections import deque

s = input()
ans = 0
now = deque()
for i in range(len(s)):
    if not now:
        now.append(s[i])
        continue
    else:
        if now[-1] != s[i]:
            ans +=2
            now.pop()
        else:
            now.append(s[i])
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
cnt = Counter(input())
print(min(cnt['0'],cnt['1'])*2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
stack=[]
cnt=0
for s in S:
    if not stack: stack.append(s)
    elif stack[-1]!=s:
        stack.pop()
        cnt+=2
    else: stack.append(s)
print(cnt)

Submission status: Accepted

Solution code:
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
# from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    S = input().rstrip()
    N = len(S)
    red_cnt = 0
    blue_cnt = 0
    ans = 0
    for i in range(N):
        if S[i] == '0':
            red_cnt += 1
            if blue_cnt > 0:
                red_cnt -= 1
                blue_cnt -= 1
                ans += 2
        else:
            blue_cnt += 1
            if red_cnt > 0:
                red_cnt -= 1
                blue_cnt -= 1
                ans += 2
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()

count0 = count1 = 0
for i in S:
    if i == "0":
        count0 += 1
    else:
        count1 += 1
print(min(count0, count1) * 2)

Submission status: Accepted

Solution code:
N = list(input())
N2 = list(map(int,N))

if len(N2) == 1:
  print("0")
  exit()

counter = 0
c = 1

while len(N2) > 0 and c <= len(N2)-1:
  # print(N2,c)
  before = N2[c-1]

  if before == 0 and N2[c] == 1:
    N2.pop(c-1)
    N2.pop(c-1)

    c -= 2
    counter += 2

    if len(N2) == 0:
      break

    if c <= 0:
      before = N2[0]
      c = 1
    else:
      before = N2[c-1]

  elif before == 1 and N2[c] == 0:
    N2.pop(c-1)
    N2.pop(c-1)

    c -= 2
    counter += 2

    if len(N2) == 0:
      break

    if c <= 0:
      before = N2[0]
      c = 1
    else:
      before = N2[c-1]

  else:
    c += 1

print(counter)

Submission status: Accepted

Solution code:
def unification(S):
    cnt_0 = S.count('0')
    cnt_1 = S.count('1')
    return 2 * min(cnt_0, cnt_1)

S = input()
print(unification(S))

Submission status: Accepted

Solution code:
def count_0_and_1(S):
    cnt_0 = 0
    cnt_1 = 0
    for i in S:
        if i == '0':
            cnt_0 += 1
        if i == '1':
            cnt_1 += 1
    return cnt_0, cnt_1


S = input()
minRB = min(count_0_and_1(S))

print(2*minRB)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
cnt_zero = s.count('0')
cnt_one = len(s) - cnt_zero
print(min(cnt_one, cnt_zero)*2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

s=list(input())

S=Counter(s)

print(len(s)-abs(S["1"]-S["0"]))

Submission status: Accepted

Solution code:

S = list(input())
N = len(S)
num = [0,0]
for s in S:
    num[int(s)] += 1
    
print(N-(max(num)-min(num)))

Submission status: Accepted

Solution code:
S = input()
N = len(S)

cntr = 0
cntb = 0
for i in range(N):
    if S[i] == '0':
        cntr += 1
    else:
        cntb += 1
        
print(2 * min(cntr, cntb))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
count=0

A=S.count('0')
B=S.count('1')

print(A+B-abs(A-B))

Submission status: Accepted

Solution code:
S = input()
r = S.count("0")
l = len(S)
b = l-r
print(2*min(b,r))

Submission status: Accepted

Solution code:
S = input()
cnt0 = S.count("0")
cnt1 = S.count("1")

print(2*min(cnt0,cnt1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())

ans = 0
s_dict = {'0':0, '1':0}
for i in range(len(S)):
    if s_dict['0'] == 0 and s_dict['1'] == 0:
        s_dict[S[i]] += 1
    elif s_dict['0'] == 0:
        if S[i] == '0':
            s_dict['1'] -= 1
            ans += 2
        elif S[i] == '1':
            s_dict['1'] += 1
    elif s_dict['1'] == 0:
        if S[i] == '0':
            s_dict['0'] += 1
        elif S[i] == '1':
            s_dict['0'] -= 1
            ans += 2
print(ans)

Submission status: Accepted

Solution code:
S = input()
a = sum([int(S[i]) for i in range(len(S))])
b = len(S) - a
print(2*min(a, b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

print(2 * min(one, zero))

Submission status: Accepted

Solution code:
from collections import Counter

s = input()
c = Counter(s)
answer = min(c.get("0", 0), c.get("1", 0)) * 2
print(answer)

Submission status: Accepted

Solution code:
s  = input()

one = len([i for i in s if i == '1'])
zero = len(s)- one

print(2*min(one,zero))

Submission status: Accepted

Solution code:
s = list(int(x) for x in input())
a = s.count(0)
b = s.count(1)
print(min(a, b) * 2)

Submission status: Accepted

Solution code:
s = input()

zeros = 0
ones = 0
for i in range(len(s)):
    if s[i] == '0':
        zeros += 1
    if s[i] == '1':
        ones += 1

print(min(zeros,ones)*2)

Submission status: Accepted

Solution code:
S = str(input())

a = 0
b = 0
for i in range(len(S)):
  if S[i] == "1":
    a += 1
  else:
    b += 1

print(min(a, b)*2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def test():
    s = input()
    c_0 = s.count("0")
    c_1 = s.count("1")
    if c_0 != 0 and c_1 != 0:
        print(2*min(c_0,c_1))
    else:
        print(0)


if __name__ == "__main__":
    test()

Submission status: Accepted

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

Submission status: Accepted

Solution code:


import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
##############################


def main():
    S = input().rstrip()
    zero = S.count("0")
    one = S.count("1")

    print ( min(zero, one) * 2 )

main()

Submission status: Accepted

Solution code:
#C - Unification(ABC120)
S=input()
A0=S.count("0")
A1=len(S)-A0
print(min(A0,A1)*2)

Submission status: Accepted

Solution code:
S = list(input())

original_length = len(S)

for i in range(len(S)-1, 0, -1):
    if len(S) > i:
        if S[i-1] != S[i]:
            del S[i-1:i+1]

print(original_length - len(S))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
a = []
for s in S:
    try:
        if s != a[-1]:
            a.pop()
        else:
            a.append(s)
    except:
        a.append(s)
print(len(S)-len(a))

Submission status: Accepted

Solution code:
S = input().strip()
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=input()
k0=s.count("0")
k1=s.count("1")
print(2*min(k0,k1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
a = []
for s in S:
    if not a:
        a.append(s)
        continue
    if s != a[-1]:
        a.pop()
    else:
        a.append(s)
print(len(S)-len(a))

Submission status: Accepted

Solution code:
S = input()

cnt_1 = S.count('1')
cnt_0 = S.count('0')
ans = len(S) - abs(cnt_1 - cnt_0)
print(ans)

Submission status: Accepted

Solution code:
S=input()

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

Submission status: Accepted

Solution code:
s = input()

one = s.count('1')
zero = s.count('0')
ans = 2*min(one,zero)
print(ans)

Submission status: Accepted

Solution code:
S = list(input())

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

print(min(zero, one)*2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
zero=0
for i in range(len(S)):
  if S[i]=="0":
    zero+=1
one=len(S)-zero

print(2*min(zero,one))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
S=input()
dt=[0,0]
for s in S:
    dt[int(s)]+=1
print(min(dt)*2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

cnt_z = S.count('0')
cnt_o = S.count('1')

print (min(cnt_z, cnt_o) * 2)

Submission status: Accepted

Solution code:
s = input()
zero = 0
one = 0
for i in s:
  if i == '0':
    zero += 1
  else:
    one += 1
print(min(zero, one) * 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    S = str(input())
    count1 = 0
    for s in S:
        if s =='1':
            count1 += 1
    count0 = len(S) - count1
    print(2*min(count0, count1))

Submission status: Accepted

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

print(ans*2)

Submission status: Accepted

Solution code:
S = input()
N = len(S)

count = [0, 0]
for s in S:
    count[int(s)] += 1

res = min(count) * 2
print(res)

Submission status: Accepted

Solution code:
s = input()

red = 0
blue = 0
for i in range(len(s)):
    if s[i] == "0":
        red += 1
    else:
        blue += 1
        
result = min(red,blue)*2
print(result)

Submission status: Accepted

Solution code:
S = input()

red = 0
blue = 0
for i in range(len(S)):
    if S[i] == "0":
        red += 1
    else:
        blue += 1
        
ans = min(red,blue)*2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(map(int,input()))
print(2*min(s.count(0),s.count(1)))

Submission status: Accepted

Solution code:
s = list(input())
a = []
c = 0
for i in s:
    if a == []:
        a.append(i)
    elif a[-1] != i:
        a.pop()
        c += 2
    else:a.append(i)
print(c)

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
temp = input()
s = [int(elm) for elm in temp]

oneNum = sum(s)
zeroNum = len(s) - oneNum
deleteNum = min(oneNum*2, zeroNum*2)

print(deleteNum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
array = []
for i in range(len(S)):
    array.append(S[i])
print(len(S)-abs(array.count('0')-array.count('1')))

Submission status: Accepted

Solution code:
s = list(input())

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

Submission status: Accepted

Solution code:
S = input()
N = len(S)
N0 = S.count("0")
N1 = S.count("1")
r = 2*min(N0, N1)
print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque

s = input()
cnt = 0
i = 0
n = len(s)
stack = deque()
updated = True
while updated:
    updated = False
    while i < n and len(stack) > 0 and stack[-1] != s[i]:
        updated = True
        stack.pop()
        i += 1
        cnt += 2
    if i < n:
        updated = True
        stack.append(s[i])
    i += 1
# print(stack)
print(cnt)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  msg=list(input())
  a=msg.count("1")
  b=len(msg)-a
  print(2*min(a,b))
main()

Submission status: Accepted

Solution code:
def main():
  msg=list(input())
  a,b=0,0
  for _ in msg:
    if _ == "0":
      a+=1
    else:
      b+=1
  ans=2*min(a,b)
  print(ans)    
main()

Submission status: Accepted

Solution code:
def main():
  msg=list(input())
  import collections as col
  cnt=col.Counter(msg)
  blue,red=cnt["1"],cnt["0"]
  ans=2*(min(blue,red))
  print(ans)  
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input().strip()
a, b = 0, 0
for c in s:
    if c == '0':
        a += 1
    else:
        b += 1
print(a + b - abs(a - b))

Submission status: Accepted

Solution code:
s = sorted(input())
point = 0
for i in range(len(s)):
    if s[i] == '1':
        point = i
        break
print(len(s)-(max(point, len(s)-point)-min(point, len(s)-point)))

Submission status: Accepted

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

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()
stack=[]
count=0

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

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 = list(input())

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

print(int(zero*2) if zero <= one else int(one*2))

Submission status: Accepted

Solution code:
s=input()

dd='0'
ee='1'
ze=0
on=0

for i in range(len(s)):
    if s[i]==dd:
        ze+=1
    else:
        on+=1
print(min(ze,on)*2)

Submission status: Accepted

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

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()

s = list(s)

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

Submission status: Accepted

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

print(min(count0, count1)*2)

Submission status: Accepted

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