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 (Python):

S = list(input())
zero = 0
one = 0
ans = 0
for s in S:
    if s == '0':
        zero += 1
        if one > 0:
            zero -= 1
            one -= 1
            ans += 2
    else:
        one += 1
        if zero > 0:
            zero -= 1
            one -= 1
            ans += 2
print(ans)

Solution (Python):
from collections import deque
S = input()
dq = deque()
for s in S:
    if not(dq):
        dq.append(s)
        continue
    if int(dq[-1]) + int(s) == 1:
        dq.pop()
    else:
        dq.append(s)
ans = len(S) - len(dq)
print(ans)

Solution (Python):
s = input()
zero = s.count("0")
one = s.count("1")

print(2 * min(zero, one))

Solution (Python):
S = [int(i) for i in input().split()[0]]
print(2*min(S.count(0),S.count(1)))

Solution (Python):
s = input()


ans = 0
i = 0
while True:
    
    if i > len(s) - 2:
        print(ans)
        exit()
    if s[i] != s[i + 1]:
        ans += 2
        if i == len(s) - 2:
            s = s[:i]
        else:
            s = s[:i] + s[i + 2:]
        if i >= 1:
            i -= 1
        continue

    i += 1

Solution (Python):

"""
Created on Sun Mar  3 20:59:27 2019

@author: doppe
"""
S = input()

zero = 0
ichi = 0
for c in S:
    if (c == '0'):
        zero += 1
    elif (c == '1'):
        ichi += 1

if (zero > ichi):
    deleteNum = ichi * 2
else:
    deleteNum = zero * 2

print(deleteNum)

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

Solution (Python):
s = input()
n = len(s)
zc = 0
oc = 0
for i in range(n):
    if s[i] == "0":
        zc += 1
    else:
        oc += 1
print(n - abs(zc - oc))

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

Solution (Python):


S = input()

zero = 0
one = 0

for s in S:
    if s == "0":
        zero += 1
    else:
        one += 1

print(min([zero, one]) * 2)

Solution (Python):


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

Solution (Python):
lis = list(input())
num0 = 0
num1 = 0
for item in lis:
  if item == "0":
    num0 += 1
  else:
    num1 += 1
print(min(num0,num1)*2)

Solution (Python):
S = input()
cnt = [0]*2
for i in S:
    if(i=='0'):
        cnt[0]+=1
    else:
        cnt[1]+=1
print(min(cnt[0],cnt[1])*2)

Solution (Python):
s=input()
lst=[]
ans=0
for i in range(len(s)):
    if len(lst)==0:lst.append(s[i])
    elif lst[len(lst)-1]!=s[i]:
        lst.pop(len(lst)-1)
        ans+=1
        continue
    else:lst.append(s[i])
print(ans*2)

Solution (Python):
s = input()
stack = [s[0]]
now = s[0]
ans = 0


for i in range(1,len(s)):
    cha = s[i]
    if cha == now:
        stack.append(cha)
        now = cha
        
    else:
        if now != "a":
            stack.pop()
            
            ans += 2
            if stack:
                now = stack[-1]
            else:
                now = "a"
        else:
            stack.append(cha)
            now = cha

print(ans)

Solution (Python):
S =input()
zero=list(S).count('0')
one =list(S).count('1')
print(min(zero,one)*2)

Solution (Python):
S = input()

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

print(2 * min(n0, n1))

Solution (Python):
s = input()
i = 0
for c in s:
    if c == '0':
        i = i + 1
print(2 * min(i, len(s) - i))

Solution (Python):
S = input()

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

print(len(S) - abs(i0 - i1))

Solution (Python):
s = input()

p = 0
q = 0
for i in range(len(s)):
    if s[i] == "0":
        p += 1
    if s[i] == "1":
        q += 1

print(2 * min(p,q))

Solution (Python):


S = input()

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

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

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

Solution (Python):



def main():
    s = input()
    zero_count = s.count('0')
    one_count = s.count('1')
    print(min(zero_count, one_count) * 2)


if __name__ == '__main__':
    main()

Solution (Python):

import sys

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)

Solution (Python):
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)

Solution (Python):
s = input()

s = list(s)


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

print(min(a, b) * 2)

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

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

Solution (Python):
S = input()

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

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

Solution (Python):
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)

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

print(min(a, b) * 2)

Solution (Python):






S = list(str(input()))





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

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

Solution (Python):


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)

Solution (Python):
s = input()

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

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

Solution (Python):
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)

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

Solution (Python):
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()

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

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

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

Solution (Python):
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))

Solution (Python):
from sys import stdin
input = stdin.readline

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

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

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

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

Solution (Python):
import sys

S = input()

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

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

Solution (Python):
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))

Solution (Python):
S = list(input())

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

print(min(a,b)*2)

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

Solution (Python):
S = input()

a, b = 0, 0

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

print(min(a, b) * 2)

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

Solution (Python):
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)

Solution (Python):
s = input()

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

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

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

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

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

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

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

Solution (Python):
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)

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

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

print(min(c0,c1)*2)

Solution (Python):
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))

Solution (Python):
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)

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

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

sa=abs(count0-count1)

print(len(s)-sa)

Solution (Python):
S = input()

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

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

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

print(min(R,B) * 2)

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

Solution (Python):
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))

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

Solution (Python):
N=input()


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

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

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

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

Solution (Python):


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)

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

Solution (Python):
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)

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

Solution (Python):

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

Solution (Python):
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)

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

Solution (Python):
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))

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

print(solve())

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

Solution (Python):
S=input()

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

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

Solution (Python):
s = list(input())

a = s.count('0')

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

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

Solution (Python):

s = input()

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

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

Solution (Python):
S = input()

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

Solution (Python):
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))

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

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

print(min(zero,one) * 2)

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

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

Solution (Python):

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

ans = min(a, b) * 2

print(ans)

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

print(min(a,b)*2)

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

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

Solution (Python):
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)

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

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

Solution (Python):

import re
import bisect
from datetime import datetime as dt

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

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

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):
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)

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

Solution (Python):
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)

Solution (Python):
""" AtCoder """

S = input()

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

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

Solution (Python):
S = input()

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

Solution (Python):
s = list(input())

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

print(min(r,b)*2)

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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())







a = input()                                  






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)

Solution (Python):
from collections import Counter

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)

Solution (Python):
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)

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

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

Solution (Python):
S = str(input())


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

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

Solution (Python):
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))

Solution (Python):
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))

Solution (Python):
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))

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

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

Solution (Python):
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)

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

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

Solution (Python):
a = input()

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

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

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

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):


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()

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

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

Solution (Python):
s = list(input())



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)

Solution (Python):
S = list(input())
red = S.count('0')
blue = S.count('1')
print(min(red,blue)*2)

Solution (Python):
s = input()

zeros = 0
ones = 0

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

print(min(zeros, ones)*2)

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

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

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

Solution (Python):
S = input()

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

print(min(r,b)*2)

Solution (Python):
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))

Solution (Python):

from collections import Counter
C = Counter(input())
print(min(C["0"], C["1"])*2)

Solution (Python):
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)

Solution (Python):


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)

Solution (Python):
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)

Solution (Python):
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)

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

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

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

Solution (Python):
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)

Solution (Python):
Ss = input()

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

print(min(num0, num1) * 2)

Solution (Python):

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)

Solution (Python):
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);

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

Solution (Python):
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)

Solution (Python):
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)

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

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

Solution (Python):
S = list(input())

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

print(min(a, b) * 2)

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

Solution (Python):
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))

Solution (Python):
S=input()

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

Solution (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()

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

Solution (Python):
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)

Solution (Python):
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)

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

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

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

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

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):
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))

Solution (Python):

S = input()
from collections import Counter
c = Counter(S)

print(min(c["0"], c["1"])*2)

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

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

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


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

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