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

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd



def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False



def main():
    S = input()
    stack = []
    ans = 0

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
S1 = input()
S2 = ''
res = 0

for s in S1:
    if len(S2) == 0 or S2[-1] == s:
        S2 += s
    else:
        S2 = S2[:-1:]
        res += 2

print(res)

Solution (Python):
S = input()

count_one = S.count("1")
count_zero = S.count("0")

print(min(count_one, count_zero)*2)

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

Solution (Python):
import sys
input = sys.stdin.readline
import re
def print_ans(S):
    """Test Case
    >>> print_ans("0011")
    4
    >>> print_ans("11011010001011")
    12
    >>> print_ans("0")
    0
    """
    flg = True
    ans = 0
    
    
    
    
    
    
    
    
    
    list_0 = []
    list_1 = []
    for s in S:
        if s =="0":
            list_0.append(s)
        else:
            list_1.append(s)
    print(min(len(list_0), len(list_1)) * 2)
        


if __name__ == '__main__':
    S = input().rstrip()
    print_ans(S)

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

Solution (Python):
from collections import deque

d = deque()
s=input()
ans=0
for i in s:
    d.append(i)
    if(len(d)>=2):
        if(d[len(d)-1]!=d[len(d)-2]):
            d.pop()
            d.pop()
            ans+=2
print(ans)

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

main()

Solution (Python):

S=input()
s = [int(i) for i in S]
cnt0=s.count(0)
cnt1=s.count(1)

print(2*min(cnt0,cnt1))

Solution (Python):
def judge(S):
    a = list(S)
    Num0 = a.count("0")
    Num1 = a.count("1")
    return min(Num0,Num1)*2

S = input()
print(judge(S))

Solution (Python):
S = input()

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

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

Solution (Python):
S=str(input())
count_0=0
count_1=0
for i in range(len(S)):
  if S[i]=='0':
    count_0 += 1
  else:
    count_1 += 1
answer=len(S)-abs(count_0-count_1)
print(answer)

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

Solution (Python):

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

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

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

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

Solution (Python):
li = list(input())
a = li.count("0")
import math
if a < math.ceil(len(li)/2):
    print(2*a)
else:
    print(2*(len(li)-a))

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

import collections
S= collections.Counter(S)

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




aaa =min(S.items(),key=lambda x:x[1])

print(2*aaa[1])

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()
jed = 0
nul = 0

for i in S:
    if i == "1":
        jed += 1
    else:
        nul += 1
print ((min(jed,nul)*2))

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

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

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

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

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

Solution (Python):
s = input()
n = len(s)

one = [1 if si=="1" else 0 for si in s]
tmp=sum(one)
ret = min(tmp, n-tmp)*2

print(ret)

Solution (Python):
import re

s = input()
n = len(s)

one = [1 if si=="1" else 0 for si in s]
tmp=sum(one)
ret = min(tmp, n-tmp)*2

print(ret)

Solution (Python):
n=input()
s=len(n)
if s%2==0:
    l0=n[:s//2].count("0")
    l1=s//2-l0
    r0=n[s//2:].count("0")
    r1=s//2-r0
    print(min(l0,r1)*2+min(l1,r0)*2)
if s%2==1:
    l0=n[:s//2].count("0")
    l1=s//2-l0
    r0=n[s//2+1:].count("0")
    r1=s//2-r0
    tmp=min(l0,r1)*2+min(l1,r0)*2
    if n[s//2]=="0":
        if r1-l0>0 or r0-l1>0:
            tmp+=2
    else:
        if l0-r1>0 or l1-r0>0:
            tmp+=2
    print(tmp)

Solution (Python):
s = input()

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

Solution (Python):
S = input()

red = 0
blue = 0
for c in S:
    if c == '0':
        red += 1
    elif c == '1':
        blue += 1

print(min(red, blue)*2)

Solution (Python):
s = input()
cnt = [s.count('0'), s.count('1')]

print(len(s) - (max(cnt) - min(cnt)))

Solution (Python):






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

Solution (Python):
def main():
    S = input()

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


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    S = list(map(int,list(input())))

    count_0 = 0
    count_1 = 0
    for val in S:
        if val == 0:
            count_0 += 1
        else:
            count_1 += 1
    print(min(count_0, count_1)*2)


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys
input = sys.stdin.readline
list1 = list(input())
del list1[-1]
ans = 0
def func(flist):
    count0 = 0
    for i in flist:
        if i == "0":
            count0 += 1
    count1 = len(flist)-count0
    return len(flist)-abs(count1-count0)

if __name__ == "__main__":
    print(func(list1))

Solution (Python):
S = input()
count = [0, 0]
for x in S:
    count[int(x)] += 1

print(min(count)*2)

Solution (Python):
s = input()

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

print(min(c0, c1) * 2)

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

Solution (Python):
S = input()
t = []
for s in S:
    if len(t) == 0:
        t += s
    elif t[-1] != s:
        t.pop()
    else:
        t += s
print(len(S)-len(t))

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

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

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

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

Solution (Python):
s = input()
l = []
c = 0
for i in s:
  if not l:
    l.append(i)
  else:
    if i != l.pop():
      c += 2
    else:
      l.append(i)
      l.append(i)
print(c)

Solution (Python):

s=input()

count_0=0
count_1=0

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

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

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

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

print(2*min(num1,num0))

Solution (Python):
S = input()

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

Solution (Python):
s=input()

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

if one>=zero:
  print(zero*2)
else:
  print(one*2)

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

Solution (Python):
from collections import Counter
s=input()
if len(set(s))==1:
    print(0)
else:
    c=Counter(s).most_common()
    print(c[1][1]*2)

Solution (Python):
import collections
S = list(input())
S.append('0')
S.append('1')
S_counter = collections.Counter(S)
print((S_counter.most_common()[1][1]-1)*2)

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

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

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

Solution (Python):
S = input()

count_0 = S.count('0')
count_1 = len(S) - count_0

print(2*min(count_0, count_1))

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

Solution (Python):
S = input()

zero_count = S.count('0')
one_count =S.count('1')

count = min(zero_count, one_count)

print(count * 2)

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

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

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

Solution (Python):
S = input()

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

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

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

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

Solution (Python):

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)

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

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

Solution (Python):
from sys import stdin

s = stdin.readline().rstrip()

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

print(min(a,b)*2)

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

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

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

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

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

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

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

s = input()


print(main(s))

Solution (Python):
S = input()

stack = []
ans = 0
for c in S:
    if stack and stack[0] != c:

        stack.pop()
        ans += 2
    else:

        stack.append(c)

print(ans)

Solution (Python):
 
S = input()

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

print(min(zero_number, one_number) * 2)

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

Solution (Python):


s = input()


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

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

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

Solution (Python):
N = input().strip()

length = len(N)

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)

Solution (Python):

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)

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

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

Solution (Python):
S = input()

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

print(2*min(num0,num1))

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

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

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

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

Solution (Python):
S = input()

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

less = min(A,B)

print(less * 2)

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

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

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

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

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

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

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

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

Solution (Python):

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


if __name__ == "__main__":
    main()

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

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


main()

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

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

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

Solution (Python):
s=list(input())
zan=[]
delete_pair=0
for i in range(len(s)):
    if zan==[]: 
        zan.append(i)
        
        continue
    if s[i]!=s[zan[-1]]:
        delete_pair+=1
        del zan[-1]
    else:
        zan.append(i)
    
print(delete_pair*2)

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

Solution (Python):
s = input()

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

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

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
















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

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

Solution (Python):
s  = input()

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

print(2*min(zero,one))

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

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

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

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

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

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

Solution (Python):
S = list(input())
i = 0
cnt = 0
while i < len(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)

Solution (Python):
from sys import stdin

S = stdin.readline()

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

Solution (Python):
from sys import stdin

S = stdin.readline()

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

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

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

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

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

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

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

Solution (Python):
import math


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


if __name__ == "__main__":
    func()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools 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()

Solution (Python):
S = input()

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

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

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

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

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

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

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

Solution (Python):
from collections import Counter

s=list(input())

S=Counter(s)

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

Solution (Python):

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

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

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

Solution (Python):
S=input()
count=0

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

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

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

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

print(2*min(cnt0,cnt1))

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

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

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

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

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

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

print(2 * min(one, zero))

Solution (Python):
from collections import Counter

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

Solution (Python):
s  = input()

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

print(2*min(one,zero))

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

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

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

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

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

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

Solution (Python):


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

Solution (Python):

S=input()
A0=S.count("0")
A1=len(S)-A0
print(min(A0,A1)*2)

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

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

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

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

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

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

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

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

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

Solution (Python):
S = input()

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

Solution (Python):
S=input()

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

Solution (Python):
s = input()

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

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

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

print(min(zero, one)*2)

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

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

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

Solution (Python):

S=input()
dt=[0,0]
for s in S:
    dt[int(s)]+=1
print(min(dt)*2)

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

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

Solution (Python):
S = input()

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

print (min(cnt_z, cnt_o) * 2)

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

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