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

x = int(0)
i = int(len(s))

s0 = int(len(s.replace("1","")))
s1 = i-s0

print(int(2*min(s0,s1)))

Solution (Python):
S = input()
S_list = list(S)
a = S_list.count('0')
b = S_list.count('1')
print(len(S_list) - abs(a - b))

Solution (Python):
s=raw_input().strip()
pile=[s[0]]
n=len(s)
ans=0
for i in xrange(1,n):
	if pile:
		x=pile.pop()
		if s[i]!=x:
			ans=ans+2
		else:
			pile.append(x)
			pile.append(s[i])
	else:
		pile.append(s[i])
print ans

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

Solution (Python):


import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline

def debug(*args): print("DEBUG:\t", *args, file=sys.stderr)


def combine(S, i):
    if S[i] != S[i+1]:
        S
        return S[0:i] + S[i+2:]
    else:
        assert False

def main(S, answer=0, _d=False):
    S = [int(x) for x in S]
    return solve(S, answer, _d)

def solve(S, answer=0, _d=False):
    i = 0
    while i < len(S) - 1:
        
        if S[i] != S[i+1]:
            answer += 2
            del S[i:i+2]
            i = max(i - 1, 0)
        else:
            i += 1
    debug("answer", answer)
    return answer

def check(S, expected):
    a = main(S)
    if a != expected:
        print(a)
        print("expected %d" % expected, "but %d" % a, "for", S)

if 1==0:
    check("0011", 4)
    check("101", 2)
    check("111", 0)
    check("010", 1)
    check("0", 0)
    check("11011010001011", 12)

print(main(input().strip()))

Solution (Python):
S = str(input())
S = [int(x) for x in S]
if len(S) > 2 * sum(S):
  print(2 * sum(S))
else:
  print(2 * (len(S) - sum(S)))

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

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

Solution (Python):
s = input()

res = 0
a = ""
for c in s:
    if len(a) > 0 and a[-1] != c:
        a = a[:-1]
        res += 2
    else:
        a += c
print(res)

Solution (Python):
def main():
    string = input()
    lists = list(string)
    original_len = len(lists)
    zero = lists.count('0')
    one = lists.count('1')
    print(min(zero,one)*2)
if __name__ == "__main__":
    main()

Solution (Python):
a = input()
l = len(a)
blk = a
i = 0
rem = 0
num0 = 0
num1 = 0
while i < l:
    if blk[i] == "0":
        num0 += 1
    else:
        num1 += 1
    i += 1
rem = min(num0, num1)
print(rem * 2)

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

Solution (Python):
st = input()
list_s = list(st)

delcount = 0
count_0 = list_s.count('0')
count_1 = list_s.count('1')
if count_0 < count_1:
    print(count_0 * 2)
else:
    print(count_1 * 2)

Solution (Python):
import sys
stdin = sys.stdin
def ls(): return stdin.readline()

S = ls()
num_1, num_0 = 0, 0

for s in S:

    if s == '1':
        num_1 += 1
    elif s == '0':
        num_0 += 1
print( 2 * min(num_1, num_0) )

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

print(min(one, zero)*2)

Solution (Python):

s = input()

n = len(s)

cnt0 = s.count('0')
cnt1 = s.count('1')

print(min(cnt0, cnt1)*2)

Solution (Python):
s = input()

s_0 = s.count('0')
s_1 = s.count('1')

print(min(s_0, s_1) * 2)

Solution (Python):


s=input()
sl=len(s)
l=list(s)
nl=[l.pop(0)]
si=0
while len(l)>0:
  c=l.pop(0)
  if len(nl)>0:
    if nl[si]!=c:
      nl.pop(si)
      si=si-1
    else:
      nl.append(c)
      si=si+1
  else:
    nl=[c]
    si=0

print(sl-len(nl))

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

print(N-abs((S.count("1")-S.count("0"))) if N != 1 else 0)

Solution (Python):
S = input()

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

Solution (Python):
def main():
    s = list(input())
    
    
    res = 0
    lst = []
    count = 1
    sign = 1
    for i in range(1, len(s)):
        if s[i-1] == s[i]:
            count += 1
        else:
            lst.append(count*sign)
            count = 1
            sign *= -1
    lst.append(count*sign)
    
    res = 0
    total = 0
    while True:
        
        try:
            curr = lst.pop(0)
        except:
            break
        if (total <= 0 and curr <= 0) or (total > 0 and curr > 0):
            pass
        else:
            res += min(abs(curr), abs(total))
            
        total += curr
    print(res*2)
        
        
         
    

main()

Solution (Python):
s=str(input())
r=0
b=0
for i in range(len(s)):
  if s[i]=='1':
    b+=1
  else:
    r+=1
if r<b:
  print(2*r)
else:
  print(2*b)

Solution (Python):
s=input()
a=0
b=0

for i in s:
  if i=="0":
    a+=1
  else:
    b+=1
    
if a>=b:
  print(2*b)
else:
  print(2*a)

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

Solution (Python):
s = input()
c_0 = 0
c_1 = 0
for i in s:
    if i == "0":
        c_0 += 1
    elif i == "1":
        c_1 += 1
print(min(c_0,c_1)*2)

Solution (Python):
cubes = [c for c in input()]

zero = 0
one = 0
for cube in cubes:
    if cube == "0":
        zero += 1
    else:
        one += 1

print(min(zero, one) * 2)

Solution (Python):
from sys import stdin


def b(input_string):
    _s = input_string
    s_length = len(_s)
    s = []
    for i in range(s_length):
        s.append(_s[i])
    count = 0
    i = 0
    while(i < len(s)-1):
        
        
        if s[i] != s[i+1]:
            s.pop(i)
            s.pop(i)
            count += 2
            if i != 0:
                i -= 1
        else:
            i += 1
    return count



def main():
    input_line = stdin.readline().rstrip()
    answer = b(input_line)
    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):
s_list = [int(s) for s in input()]

if s_list.count(0) < s_list.count(1):
  print(s_list.count(0) * 2)
else:
  print(s_list.count(1) * 2)

Solution (Python):
import copy

s = input()
s_sub = copy.deepcopy(s)























l1 = s.count("0")
l2 = s.count("1")
l3 = abs(l1-l2)

print(len(s_sub)-l3)

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

Solution (Python):
S = input()
one = S.count('1')
zero = S.count('0')
if one > zero:
    ans = zero * 2
else:
    ans = one * 2
print(ans)

Solution (Python):
S = input()

cnt1=0
cnt0=0
for i in range(len(S)):
    if S[i]=='0':
        cnt0+=1
    elif S[i]=='1':
        cnt1+=1
if cnt1 == 0 or cnt0 == 0:
    print(0)
else:
    if cnt1>cnt0:
        print(cnt0*2)
    else:
        print(cnt1*2)

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

Solution (Python):
S = input()
r = 0
ans = 0
T = []
for s in S:
    if T:
        if not (T[-1] == s):
            T.pop(-1)
            ans += 2
        else:
            T.append(s)
    else:
        T.append(s)
print(ans)

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

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

print cnt

Solution (Python):
s=str(input())
ue=-1
ans=0
for i in range(len(s)):
  if(ue==-1):
    ue=int(s[i])
  elif(int(s[i])!=ue):
    ans+=2
    if(ans==i+1):
      ue=-1
print(ans)

Solution (Python):
if __name__ == "__main__":
    n = input()
    a = 0
    b = 0
    for c in n:
        if(c == '1'):
            a += 1
        else:
            b += 1
    if(a>b):
        print(b*2)
    else:
        print(a*2)

Solution (Python):

import sys



def solve(lines):
    NLIST = list(lines.pop(0))
    zero = 0
    one = 0
    for i in NLIST:
        if i == '1':
            one += 1
        else:
            zero += 1
    print(min(one,zero) * 2)
    
lines = [x.strip() for x in sys.stdin.readlines()]




solve(lines)

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

Solution (Python):
S=list(input())
red=len(list(filter(lambda e:e=='0', S)))
blue=len(list(filter(lambda e:e=='1', S)))
d=abs(red-blue)
print(red+blue-d)

Solution (Python):
S = input()

print(len(S)-abs(S.count("0")-S.count("1")))

Solution (Python):
s = input()

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

if a >= b:
	print(len(s) - a + b)
else:
	print(len(s) - b + a)

Solution (Python):
s = input()

if s.count('1') > 0 and s.count('0') > 0:
  print(min(s.count('1'), s.count('0')) * 2)
else:
  print(0)

Solution (Python):
import sys

def main():
  input = sys.stdin.readline
  S = [int(c) for c in input().strip()]
  n1 = 0
  n0 = 0
  for i in S:
    if i == 0:
      n0 += 1
    else:
      n1 += 1
  print(min(n1, n0) * 2)


if __name__ == '__main__':
  main()

Solution (Python):

s = input()

n = len(s)

stack = [ s[0] ]

rem = 0




ss = len(stack)

for i in range(1,n):


    if ss==0 or stack[-1] == s[i]:

        stack.append(s[i])
        ss+=1
        
        continue


    if len(stack) > 0:
        stack.pop()
        ss -= 1

        i+=1
        rem +=2


print(rem)

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

Solution (Python):
s = input()
z=0
o=0
for c in str(s):
	if c=="0":
		z+=1
	else:
		o+=1
print((z if o > z else o)*2)

Solution (Python):
S = input()

iL = len(S)
i0 = 0
for s in S:
    if s == "0":
        i0 += 1
i1 = iL - i0
print(2*min(i1,i0))

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

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

tmp = [0 for i in range(len(S))]

for i in range(len(S)):
    if S[i] == '1':
        tmp[i] = 1
    elif S[i] == '0':
        tmp[i] = 0
     
flag = False
for i in range(len(S)-1):
    if S[i] != S[i+1] and flag == False:
        tmp[i] = -1
        tmp[i+1] = -1
        flag = True
    else:
        flag = False
  
count1 = 0
count0 = 0
res = 0
for i in range(len(S)):
    if tmp[i] == 1:
        count1 += 1
        
    elif tmp[i] == 0:
        count0 += 1
        
    else:
        res += 1
        
print(res + min(count0, count1) * 2)

Solution (Python):
from collections import Counter
try:
  print(Counter(input()).most_common()[1][1] * 2)
except:
  print(0)

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

Solution (Python):
S = list(map(int, list(input())))
s_len = len(S)
num_one = sum(S)
print(s_len - abs(num_one*2 - s_len))

Solution (Python):
import re
s = input()
first_len = len(s)

ten_3_zo = "0" * 10 * 10 * 10 + "1" * 10 * 10 * 10
ten_3_oz = "1" * 10 * 10 * 10 + "0" * 10 * 10 * 10

ten_1_zo = "0" * 10 + "1" * 10
ten_1_oz = "1" * 10 + "0" * 10


while True:
    s = s.replace(ten_3_zo,"").replace(ten_3_oz,"")
    s = s.replace(ten_1_zo,"").replace(ten_1_oz,"")
    s = s.replace("01","").replace("10","")
    if not re.search('01|10',s):
        break

print(first_len - len(s))

Solution (Python):


def main():
    s = input().split(" ")

    sl = list(s[0])
    prev = -1
    n = 0

    i = 0
    while True:
        if len(sl) <= i:
            break

        if (prev == 0 and sl[i] == '1') or (prev == 1 and sl[i] == '0'):
            
            
            del sl[i]
            del sl[i-1]
            n += 2
            if i-2 < 0:
                prev = -1
                i = 0
            else:
                prev = int(sl[i-2])
                i = i-1
        else:
            prev = int(sl[i])
            i += 1

    print(n)

main()

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

count0 = S_list.count("0")
count1 = S_list.count("1")

print(len(S_list) - abs(count0-count1))

Solution (Python):
S = input()

xs = [S[0]]
for c in S[1:]:
    if xs and xs[-1] != c:
        xs.pop()
    else:
        xs.append(c)
print(len(S) - len(xs))

Solution (Python):
S=input()
zero=0
ichi=0
N=len(S)
for i in range(N):
    if S[i]=="0":
        zero+=1
    else:
        ichi+=1

print(min(zero,ichi)*2)

Solution (Python):
S = input()
zero = S.count('0')
one = len(S) - zero
num = zero if zero <= one else one
print(num * 2)

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

Solution (Python):
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

ans = 0
z = 0
o = 0
for c in input():
    if c == '0':
        if o > 0:
            o -= 1
            ans += 2
        else:
            z += 1
    else:
        if z > 0:
            z -= 1
            ans += 2
        else:
            o += 1
print(ans)

Solution (Python):
def main():
    s = input()
    if len(s) == 0:
        print(0)

    one_counter = 0
    for i in range(len(s)):
        if s[i] == '1':
            one_counter += 1
    zero_counter = len(s) - one_counter
    print(2 * min(zero_counter, one_counter))

if __name__ == '__main__':
    main()

Solution (Python):
S = list(input())
a = S.count('0')
print(min(a,len(S)-a)*2)

Solution (Python):
s = input()

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

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

Solution (Python):
import copy
S = list(map(int,input()))
cnt0 = 0
cnt1 = 0
for i in range(len(S)):
    if S[i] == 0:
        cnt0 += 1
    else:
        cnt1 += 1

ans = cnt0 + cnt1 - abs(cnt0-cnt1)
print(ans)

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

Solution (Python):
S=input()
count=0
o=S.count("1")
z=S.count("0")
if o>=z:
    print(z*2)
else:
    print(o*2)

Solution (Python):
s = input()

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

print(ans)

Solution (Python):
s = str(input()).strip()
t = len(s)
tt = len(s.replace("1", ""))
print(2 * min(t-tt, tt))

Solution (Python):
S = input()

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

Solution (Python):
from collections import deque
s=input()
q=deque([])
q.append(s[0])

count=0
for i in s[1:]:
    if len(q)==0:
        q.append(i)
    elif i=='0':
        x=q.pop()
        if x=='1':
            count+=2
        else:
            q.append(x)
            q.append('0')
    else:
        
        x=q.pop()
        if x=='0':
            count+=2
        else:
            q.append(x)
            q.append('1')
print(count)

Solution (Python):
a = input()
b = 0
c = 0
for i in a:
  if i =="0":
    b+=1
  else:
    c+=1
if b == 0 or c == 0:
  print(0)
elif b>=c:
  print(c*2)
else:
  print(b*2)

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


if s.count('0') >= s.count('1'):
    print(s.count('1')*2)
else:
    print(s.count('0')*2)

Solution (Python):
l = input()
l1 =l
l2 =l1
l1 = l1.replace("0","")
numof0=len(l)-len(l1)
l2 = l2.replace("1","")
numof1=len(l)-len(l2)

print(min(numof0,numof1)*2)

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

Solution (Python):
"""
0011 = 4
0101 = 4
00111 = 4
01011 = 4
10011 = 4
000111 = 6
001011 = 6

0または1のいずれか個数の少ない文字を特定する
特定した文字の個数を2倍する
"""

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

Solution (Python):
s = input() 

que = list([-10])
ans = 0
for c in s:
    x = int(c)
    if abs(x-que[-1]) == 1:
        que.pop(-1)
        ans += 2
    else:
        que.append(x)
print(ans)

Solution (Python):
s = input()
S = [int(s[i]) for i in range(len(s))]

count = 0
before = 0
while 1:
    
    is_continue = False
    
    
    for i in range(max([before, 0]), len(S) - 1):
        
        
        
        if S[i] != S[i + 1]:
            
            del S[i]
            del S[i]
            count += 2
            is_continue = True
            before = i - 2
            
            break
    if not is_continue:
        break
print(count)

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

Solution (Python):
S = list(map(int,list(input())))
N = len(S)
i = 0
cnt = 0
kaisuu = 0
while(kaisuu<N):
	kaisuu += 1
	if(N==0 or N==1 or i+1>len(S)-1):
		break
	elif(S[i]!=S[i+1]):
		del S[i+1]
		del S[i]
		cnt += 1
		if(i!=0):
			i -= 1
		else:
			i = 0
	else:
		i += 1
print(2*cnt)

Solution (Python):
s = input()
S=[]
for c in s:
    S.append(int(c))

count0 = 0
count1 = 0

for i in range(len(S)):
    if S[i] == 0:
        count0 += 1
    if S[i] == 1:
        count1 += 1

remainder = max(count0, count1) - min(count0, count1)

print(len(S) - remainder)

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

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

Solution (Python):
S = list(input())
count_0 = 0
count_1 = 0


for i in S:
    if i == "0":
        count_0 += 1
    if i == "1":
        count_1 += 1

print(min(count_0, count_1)*2)

Solution (Python):
[a] = list(map(str, input().split()))

flag=1
rem1=0
count=0

for i in range(len(a)):
  if(int(a[i])==0):
    if(rem1>0):
      count+=2
      rem1-=1
    else:
      rem1-=1
  if(int(a[i])==1):
    if(rem1<0):
      rem1+=1
      count+=2
    else:
      rem1+=1

print(count)

Solution (Python):
s=input()

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

Solution (Python):
S = list(input())
count = [0]*2
for s in S:
    if s == '0':
        count[0] += 1
    else:
        count[1] += 1

print(min(count)*2)

Solution (Python):
a = input()

z = 0
i = 0
for b in a:
  if(b == '0'):
    z += 1
  else:
    i += 1
if(z >= i):
  print(i * 2)
else:
  print(z * 2)

Solution (Python):
a = input()
count0 = 0
count1 = 0
b = len(a)
for i in range(b):
    if(a[i] == "0") :
        count0 = count0 + 1
    else:
        count1 = count1 + 1

print(min(count0,count1)*2)

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

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

print(min(a,b)*2)

Solution (Python):
wlist = list(input())
cnt = 0

for i in wlist:
    if i == "1":
        cnt += 1
if (len(wlist) - cnt) > cnt:
    print(2*cnt)

else:
    print(2*(len(wlist)-cnt))

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

Solution (Python):
import numpy as np

S = input()
N = int(len(S))
lst = [int(S[i]) for i in range(N)]

if N % 2 == 0:
  med = int(N/2)
else:
  med = int(N/2 + 1)

left = lst[:med]
right = lst[med:]

left_blue = np.sum(left)
left_red = len(left) - left_blue
right_blue = np.sum(right)
right_red = len(right)-right_blue

ans = N - (np.abs(left_red-right_blue) + np.abs(left_blue-right_red))

print(int(ans))

Solution (Python):
s = list(input())
x = list(map(int, s))
k = 0
for i in range(len(x)):
    if x[i] == 0:
        k += 1
print(2 * min(k, len(x) - k))

Solution (Python):
S = input()
lst1 = sum([1 for x in S if x == '1'])
lst2 = sum([1 for x in S if x == '0'])
print(min(lst1, lst2) * 2)

Solution (Python):
S = input()

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

Solution (Python):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

S=input()
N=len(S)

buf = []
h = 0
ans = 0
for s in S:
    if s=='0':
        h -= 1
    else:
        h += 1
ans = N-abs(h)

print(ans)

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

Solution (Python):

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

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()
blue = red = 0
for i in range(len(s)):
  if s[i] == '0':
    red += 1
  else:
    blue += 1
print(min(red,blue)*2)

Solution (Python):


import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 


S = input()

cnt_1 = 0
cnt_0 = 0

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

print(min(cnt_1,cnt_0) * 2)

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

Solution (Python):
S = input()

n = len(S)

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

print(n-red-blue)

Solution (Python):
S = input()

count_z = S.count('0')
count_o = S.count('1')

if count_o < 1 or count_z < 1:
    print(0)
else:
    print(min(count_z,count_o)*2)

Solution (Python):


import sys
 
s = str(input())
ans = 0

for c in s:
  if c == '0':
    ans -= 1
  else:
    ans += 1
print(len(s) - abs(ans))

Solution (Python):
from sys import stdin

def main():
    S = input()

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

input = lambda: stdin.readline().rstrip()
main()

Solution (Python):
S = str(input())
cnt1 = 0
cnt2 = 0
for i in range(len(S)):
    if S[i] == "0":
        cnt1 += 1
    else:
        cnt2 += 1

if cnt1 < cnt2:
    print(cnt1*2)
else:
    print(cnt2*2)

Solution (Python):
s = input()
one = s.count("1")
zero = s.count("0")
if one == 0 or zero == 0:
    print(0)
else:
    if one >= zero:
        print(zero*2)
    else:
        print(one*2)

Solution (Python):
S = input()
cnt = 0
prev = 0
while prev != len(S):
    prev = len(S)
    ans = []
    for i, n in enumerate(S):
        if i == 0:
            ans.append(n)
            continue
        if len(ans) > 0 and ans[-1] != n:
            ans.pop()
            cnt += 2
        else:
            ans.append(n)
    S = ''.join(ans)
print(cnt)

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

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

print(min(a,b)*2)

Solution (Python):
s = input()
q = []
l = 0
o = 0
for c in s:
    q.append(c)
    l += 1
    while 1 < l and q[l-1] != q[l-2]:
        q.pop()
        q.pop()
        o += 2
        l -= 2
print(o)

Solution (Python):
def main():
    str = input()
    str_list = [int(num) for num in list(str)]
    one_counter = 0

    for number in str_list:
        if number == 1:
            one_counter += 1

    zero_counter = len(str_list) - one_counter
    more = zero_counter if zero_counter < one_counter else one_counter
    print(2 * more)


if __name__ == '__main__':
    main()

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

num_red = S.count('0')
num_blu = S.count('1')

diff = min(num_red, num_blu)

ans = diff*2

print(ans)

Solution (Python):
s = input()

l = []
for i in range(len(s)):
    l.append(int(s[i]))

def fn(lll):
    if len(lll) < 2:
        return

    if lll[-1] != lll[-2]:
        lll.pop()
        lll.pop()
        fn(lll)

ll = []
for i in l:
    ll.append(i)
    fn(ll)

print(len(l) - len(ll))

Solution (Python):
S=input()
ans=0
i=len(S)-1
while len(S)>1 and i>0:
  if S[i]!=S[i-1]:
    S=S[:i-1]+S[i+1:]
    if i==len(S)+1:
      i-=1
    ans+=2
  i-=1
print(ans)

Solution (Python):
l = [int(s) for s in list(input())]
n0 = l.count(0)
n1 = l.count(1)
print(len(l) - abs(n1-n0))

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

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

print(len(S)-abs(S.count('0')-S.count('1')))

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

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

for i in range(len(cube)):
    if cube[i] == "0":
        red += 1
    else:
        blue += 1

print(min(red, blue)*2)

Solution (Python):
s=input()

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

Solution (Python):
s = raw_input().strip()
N = len(s)
l = [int(c) for c in s]

nl = []
i = 0
while i < N:
    if len(nl) > 0:
        a = nl[-1]
        b = l[i]

        if a + b == 1:
            nl.pop()
            i += 1
        else:
            nl.append(l[i])
            i += 1
    else:
        nl.append(l[i])
        i += 1

print N - len(nl)

Solution (Python):
s = input()

m_cnt = min(s.count('0'), s.count('1'))

print(m_cnt*2)

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

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

Solution (Python):
import re

S = input()

count_1 = len(re.findall('1', S))
count_0 = len(re.findall('0', S))

if(count_1 < count_0):
    print(2 * count_1)
else:
    print(2 * count_0)

Solution (Python):
import sys






"""Template"""


class IP:
    """
    入力を取得するクラス
    """

    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        
        
        
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x // y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def gcd(self, x, y):
        if y == 0:
            return x
        else:
            return self.gcd(y, x % y)


"""ここからメインコード"""


def aa(li):
    for i in range(len(li) - 1):
        if li[i] != li[i+1]:
            return i
    return "END"


def main():
    
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    
    s = list(ip.S())
    n = len(s)
    iti = s.count("1")
    zero = s.count("0")
    print(min(iti, zero) * 2)



main()

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

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

Solution (Python):
S=input()
firstS=len(S)
zero=S.count('0')
one=S.count('1')
if zero!=0 and one!=0:
    print(2*min(one,zero))
else:
    print(0)

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

count_1 = 0
count_0 = 0

for i in s:
    if i == "1":
        count_1 += 1
    elif i == "0":
        count_0 += 1

ans = min(count_0, count_1) * 2
print(ans)

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

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

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

print(a + b - abs(a-b))

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

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

if a>b:
    print(2*b)
else:
    print(2*a)

Solution (Python):
s=input()
a=0
b=0
c=0
for i in range(len(s)):
    if c==0:
        b=s[i]
        c+=1
    elif not b==s[i]:
        a+=2
        c-=1
    else:
        b=s[i]
        c+=1
print(a)

Solution (Python):
s = input()

last_c = ''
stock_count = 0
remove_count = 0

for c in s:
	
	if last_c == c:
		stock_count += 1
		continue
		
	
	
	if stock_count == 0:
		last_c = c
		stock_count += 1
		continue
		
	stock_count -= 1
	remove_count += 1
	
print(remove_count*2)

Solution (Python):
S = input()
zerocounter = 0
for i in S:
    if i == '0':
        zerocounter += 1
n = len(S)
onecounter = n - zerocounter
print(2*min(onecounter, zerocounter))

Solution (Python):
def main():
    s = input()
    zeros = 0
    ones = 0
    for c in s:
        if c == '0':
            zeros += 1
        elif c == '1':
            ones += 1
    print(min(zeros, ones) * 2)

main()

Solution (Python):
S = input()

zeros = S.count('0')
total = len(S)
ones = total - zeros
print(min(zeros, ones) * 2)

Solution (Python):
s=input()

r=0
s0=0
s1=0

for x in s:
  if x=="0":
    if s1!=0:
      s1=s1-1
    else:
      s0=s0+1
  else:
    if s0!=0:
      s0=s0-1
    else:
      s1=s1+1


print(len(s)-s0-s1)