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

Solution (Python):
S = input()
red = S.count('0')
blue = S.count('1')
diff = max(red, blue) - abs(red - blue)
print(diff * 2)

Solution (Python):

"""
Created on Wed Mar  6 16:12:40 2019

@author: iwata
"""

S = input()
zc = S.count('0')
oc = S.count('1')
if zc >= oc:
    print(2*oc)
else:
    print(2*zc)

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

Solution (Python):
string = str(input())
zero = 0
one = 0
chars = set(string)
for char in string:
    if char == list(chars)[0]:
        zero += 1
    else:
        one += 1

if zero == 0 or one == 0:
    print(0)
else:
    print(min(zero, one) * 2)

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

Solution (Python):
S = list(map(int,input()))
n_one = S.count(1)
n_zero = S.count(0)

print(2 * min(n_zero,n_one))

Solution (Python):
print(min(map(input().count,'01'))*2)

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

Solution (Python):
ans=0
stack=[]
for s in input():
    if len(stack)>0 and stack[-1]!=s:
        del stack[-1]
        ans+=2
    else:
        stack.append(s)
print(ans)

Solution (Python):




















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

Solution (Python):
s=input()
sum1=len([i for i in s if i=="1"])
sum0=len([i for i in s if i=="0"])
if sum1>sum0:
	print(sum0*2)
else:
	print(sum1*2)

Solution (Python):
S = input()

zeroSum = 0
oneSum = 0
for _ in S:
  if _ == "0":
    zeroSum += 1
  if _ == "1":
    oneSum += 1

t = max(zeroSum, oneSum) - min(zeroSum, oneSum)
print(len(S) - t)

Solution (Python):
s = input()
s=list(s)
zeroc=0
onec=0
for i in s:
  if i == "0":
    zeroc+=1
  if i == "1":
    onec+=1
print(min(zeroc,onec)*2)

Solution (Python):
a = input()
k = []
k.append(a[0])
s = 0
for i in range(1,len(a)):
    if len(k) !=0:
        if k[-1] != a[i]:
            s+=1
            k.pop()
        else:k.append(a[i])
    else:
        k.append(a[i])

print(s*2)

Solution (Python):
string = input()
one = 0
zero = 0

for s in string:
    if s == '1':
        one += 1
    else:
        zero += 1

print(2*min(one, zero))

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

Solution (Python):
from collections import deque
S = input()
S = list(S)
counter = 0
que = deque([])
stack = deque([])
for i in range(len(S)):
    que.append(S[i])
for i in range(1000000):
  if stack:
    1
  else:
    if que:
      stack.append(que.popleft())
    else:
      break
  if que:
    s1 = que.popleft()
  else:
    break
  s2 = stack.pop()
  if(s1 != s2):
    counter+=2
  else:
    stack.append(s1)
    stack.append(s2)
print(counter)

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

Solution (Python):
S = input()

d = [0, 0]
for c in S:
    d[int(c)] += 1

print(2 * min(d))

Solution (Python):
s=input()
stk=0
h=0
for c in s:
  x=int(c)
  if x==1:
    if stk<0:
      h+=1
    stk+=1
  else:
    if stk >0:
      h+=1
    stk -=1
print(2*h)

Solution (Python):
l = input()
r = 0;
b = 0;

for c in l:
    if c == "0":
        r +=1
    else:
        b+=1

print(min(r,b)*2)

Solution (Python):
string = input()
ones = 0
zeros = 0
for s in string:
  if s == '1':
    ones += 1
  else:
    zeros += 1
print(2*min(ones, zeros))

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

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

flg = None
stack = []
for v in s:
    if not stack:
        stack.append(v)
    elif stack[-1] != v:
        del stack[-1]
    else:
        stack.append(v)
print(len(s) - len(stack))

Solution (Python):
S = input()

l0 = 0
l1 = 0

for i in S:
    if i == '0':
        l0 += 1
    elif i == '1':
        l1 += 1

ans = min(l0, l1) * 2

print(ans)

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

Solution (Python):
print(2*min(map(input().count,"01")))

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

Solution (Python):


S = input()

l0, l1 = 0, 0
for s in S:
    if s == '0':
        l0 += 1
    elif s == '1':
        l1 += 1

print(min(l0, l1) * 2)

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

Solution (Python):
S = input()
s=[]
c0=0
c1=0
for i in S:
  if i == '0':
    c0 += 1
  else:
    c1 += 1
print(c0+c1-abs(c0-c1))

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

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

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

Solution (Python):
S = input()
N = len(S)
r = 0
l = None
c = 0
for i in range(N):
  if c==0:
    l = S[i]
    c += 1
  elif S[i]==l:
    c += 1
  else:
    c -= 1
    r += 2
print(r)

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

Solution (Python):
from collections import Counter

S = Counter(input()).most_common()[::-1]

if len(S) == 1:
    print(0)
else:
    print(S[0][1] * 2)

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

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

Solution (Python):
S = input()

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

print(min(count_0, count_1) * 2)

Solution (Python):
S = input()
stack = []

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

Solution (Python):
S = input()

stack = []

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

print(ans)

Solution (Python):
S = input()

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

Solution (Python):
s = input()

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

print(min(zero,one)*2)

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

Solution (Python):

"""
Created on Tue Mar  5 00:23:16 2019

@author: yuta
"""
from collections import Counter
S = input()
def main(s):
    s = list(s)
    c = Counter(s)
    s_len = len(list(set(s)))
    if s_len == 1:
        min_count = 0
    else:
        min_count = c.most_common()[-1][1]
    print(min_count * 2)
main(S)

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

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

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

Solution (Python):
def compute():
    from sys import stdin
    S = stdin.readline().strip()
    l = len(S)

    x = S.count("1")
    y = min(x, l-x)
    print(y<<1)

if __name__ == "__main__":
    compute()

Solution (Python):
def compute():
    from sys import stdin
    S = stdin.readline().strip()

    wew = []
    for x in S:
        if len(wew)>0 and wew[-1]!=x:
            wew.pop()
        else:
            wew.append(x)

    print(len(S) - len(wew))

if __name__ == "__main__":
    compute()

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

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

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

for c in S:
    if not stack or stack[-1] == c:
        stack.append(c)
    else:
        stack.pop()
        ans += 2
        
print(ans)

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

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

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

print(ans)

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

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

Solution (Python):
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

S = list()
zero = 0
one = 0
line = readline()

for i in line:
  if i == '\n':
    break
  n = int(i)
  S.append(n)
  if n == 0:
    zero += 1
  else:
    one += 1

if zero > one:
  print(one * 2)
else:
  print(zero * 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()

start_len = len(s)

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

end_len = abs(num_1 - num_0)

print(abs(end_len - start_len))

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

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

Solution (Python):





a =input()
N=list(a)
b=0
r=0
for i in N:
    if(i=="0"):
        b+=1
    else:
        r+=1
ans=r
if(r>b):
    ans=b
print(ans*2)

Solution (Python):



from collections import Counter

def main():
  s = input().strip()
  cnt = Counter(s)
  if len(cnt) == 1:
    print(0)
  else:
    print(2*min(cnt.values()))
  pass

if __name__=='__main__':
  main()

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

n_0 = sum([1 for ss in s if ss == '0'])
diff = abs(n_0 - (n-n_0))
print(n - diff)

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

Solution (Python):
S=input()

cnt=0
for i in range(len(S)):
    if S[i]=="0":
        cnt+=1
    else:
        cnt-=1
print(len(S)-abs(cnt))

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

Solution (Python):
s = input().rstrip("\n")
from collections import Counter
count = Counter(s)
if len(count.values()) < 2:
  print(0)
else:
  print(min(count.values()) * 2)

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

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

Solution (Python):
a = list(input())
count0 = 0
count1 = 0

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

print(min(count0,count1)*2)

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

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

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

Solution (Python):
S = input()
a = S.count("0")
b = len(S) - a
print(min(a,b)*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):
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):
s=input()
st=[]
ans=0
for i in s:
  
  if i=="0":
    if not st or st[-1]=="0":
      st.append(i)
    elif st[-1]=="1":
      st.pop()
      ans+=2
  elif i =="1":
    if not st or st[-1]=="1":
      st.append(i)
    elif st[-1]=="0":
      st.pop()
      ans+=2
      

print(ans)

Solution (Python):
n=input()
maru=n.count("0")*2
iti=n.count("1")*2
if maru<iti:
  print(maru)
else:
  print(iti)

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

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

cnt = [0,0]
for i in s:
    if i==0:
        cnt[0] += 1
    else:
        cnt[1] += 1
print(min(cnt)*2)

Solution (Python):
from collections import Counter
s=input()
counter=Counter(s)
print(len(s)-abs(counter['0']-counter['1']))

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

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

Solution (Python):
s=input()

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

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

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

Solution (Python):
S = input()
ans = 0
stack = []
for si in S:
    if stack and si!=stack[-1]:
        stack.pop()
        ans += 2
    else:
        stack.append(si)
print(ans)

Solution (Python):

s = input()
print(s.count('0')*2 if s.count('0') < s.count('1') else s.count('1')*2)

Solution (Python):
s = input()

cnt0 = 0
cnt1 = 0

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

Solution (Python):
s = input()
 
ans = 0
stack = []
 
for c in s:
  if stack == []:
    stack.append(c)
    continue
  if c != stack[-1]:
    ans += 2
    stack.pop(-1)
  else:
    stack.append(c)
    
print(ans)

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

S_1 = [S[i] for i in range(len(S)) if S[i]==1]
S_0 = [S[i] for i in range(len(S)) if S[i]==0]

S_min = min(len(S_1), len(S_0))

print(2*S_min)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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 LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    q = collections.deque()
    r = 0
    for c in s:
        if q and q[-1] != c:
            r += 2
            q.pop()
        else:
            q.append(c)

    return r



print(main())

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

Rc=s.count('1')
Bc=s.count('0')

print(min(Rc,Bc)*2)

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

    ans = f(S)
    print(ans)


def f(S):
    stack = []
    ans = 0
    for c in S:
        if stack and stack[-1] != c:
            ans += 2
            stack.pop()
        else:
            stack.append(c)
    return ans


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
S = input()

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

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

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

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

Solution (Python):


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

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

Solution (Python):

"""
a, b, c = map(int, input().split())
print(min(b//a, c))
"""

"""
a, b, k = map(int, input().split())
for i in range(max(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        k -= 1
        if k == 0:
             print(i)
"""


s = list(input())
an0 = 0
an1 = 0
for i in s:
    if i == "1":
        an1 += 1
    if i == "0":
        an0 += 1
print(min(an0, an1)*2)

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

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

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

def counter(array):
    from collections import Counter
    return list(Counter(array).most_common())
c = counter(s)
if len(c) == 2:
    cnt = min(c[0][1],c[1][1])
print(cnt*2)

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

Solution (Python):

S = list(map(int, list(input().rstrip())))
v1 = sum(S) 
r = min(v1, len(S) - v1) 
print(r * 2)

Solution (Python):
S = input()
zc = S.count('0')
oc = S.count('1')


print(zc * 2 if zc < oc else oc * 2)

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

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

Solution (Python):
import sys


S = sorted(list(input()))
L = len(S)

num0 = 0
for i in range(L):
    if(S[i] == "1"):
        num0 = i
        break
print(min((L-num0)*2,num0*2))

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

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

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

Solution (Python):
S = list(input())
length1 = S.count('0')
length2 = S.count('1')
if length1 < length2:
    print(length1*2)
else:
    print(length2*2)

Solution (Python):
import sys
s = list(sys.stdin.readline())
l = len(s)
cnt0, cnt1 = 0, 0
for i in s:
    if "0" in i:
        cnt0 += 1
    elif "1" in i:
        cnt1 += 1

print(min(cnt0, cnt1)*2)

Solution (Python):

s = list(input())
n = len(s)

st = []
res = 0
for i in range(n):
    if len(st)>0:
        top = st[-1]
        if s[i]!=top:
            res += 2
            st.pop()
        else:
            st.append(s[i])
    else:
        st.append(s[i])
print(res)

Solution (Python):
s = input()
print(2 * min([sum([v == '1' for v in s]), sum([v == '0' for v in s])]))

Solution (Python):
def unification(S: str) -> int:
    c0 = sum([int(c) for c in S])
    c1 = sum([1 - int(c) for c in S])

    return min(c0, c1) * 2


if __name__ == "__main__":
    S = input()
    answer = unification(S)
    print(answer)

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('1')*2, S.count('0')*2 ))

Solution (Python):

from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007


"""
a,b,c = LI()
print(min(b//a,c))
"""


"""
a,b,k = LI()
i = 1
ans = [1]
while i <= min(a,b):
    i += 1
    if a%i == 0 and b%i == 0:
        ans.append(i)
print(ans[-k])
"""


s = list(map(int,S()))
print(2*min(sum(s),len(s)-sum(s)))


"""
def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]
def unite(x,y):
    x = root(x)
    y = root(y)
    if x == y:
        ans.append(ans[-1])
        return
    sx = s[x]
    sy = s[y]
    if rank[x] < rank[y]:
        par[x] = y
        s[y] += sx
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1
        s[x] += sy
    ans.append(ans[-1]+sx*sy)
n,m  = LI()
v = LIR(m)
v = v[::-1]
par = [i for i in range(n)]
rank = [0 for i in range(n)]
s = [1 for i in range(n)]
ans = [0]
k = n*(n-1)//2
v.pop(-1)
for a,b in v:
    if ans[0] == k:
        ans.append(k)
        continue
    a -= 1
    b -= 1
    unite(a,b)
for i in ans[::-1]:
    print(k-i)
"""

"""
n,a,b = LI()
s = input()
ans = 0
i = 0
while i < n:
    j = i+1
    if s[i:j] in s[:i]:
        while s[i:j] in s[:i]:
            j += 1
            if j >= n-1:break
        ans += min(b,a*(j-i))
    else:
        ans += a*(j-i)
    i = j
print(ans)
"""

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

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()
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):
S = input()
ans = 0
res = ''
for i in range(len(S)):
    if len(res) and res[-1] != S[i]:
        res = res[:-1]
        ans += 2
    else:
        res += S[i]
print(ans)

Solution (Python):
S = input()
stack = []
cnt = 0

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

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

Solution (Python):
from collections import deque
S = deque(input())
S2 = deque([])
counter = 0
while True:
    if len(S) == 0:
        break
    s = S.popleft()
    if len(S2) == 0:
            S2.append(s)
            continue
    
    elif s!=S2[-1]:
            S2.pop()
            counter +=2
    else:
        S2.append(s)
print(counter)

Solution (Python):
s=input()

x=s.count('1')
y=s.count('0')

a=max(x,y)
b=min(x,y)

print(len(s)-(a-b))

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

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

Solution (Python):
import sys


fin = sys.stdin.readline
S = fin().rstrip("\n")

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):
s = input()
zero = s.count('0')
one = s.count('1')
print(2*min(zero, one))

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

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

Solution (Python):
def daruma(s):
    ans = 0
    s_stack = [s[0]]
    for i in range(1, len(s)):
        if len(s_stack) != 0:
            if s_stack[-1] + s[i] == "01" or s_stack[-1] + s[i] == "10":
                s_stack.pop()
                ans += 2
            else:
                s_stack.append(s[i])
        else:
            s_stack.append(s[i])
    return ans

def main():
    s = input()
    ans = daruma(s)
    print(ans)

main()

Solution (Python):
S = input()
S_list = []
i = 0
for s in S:
    S_list.append(s)

count_0 = S_list.count('0')
count_1 = S_list.count('1')

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

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

Solution (Python):
import sys
fin = sys.stdin.readline
ob = list(fin())
print(min(ob.count("0"), ob.count("1"))*2)

Solution (Python):
import numpy as np
import copy

cubes = list(input())
cubes = np.array(list(map(int, cubes)))

zeroNum = 0
oneNum = 0
for i in range(0, len(cubes)):
    if cubes[i] == 0:
        zeroNum += 1
    else :
        oneNum += 1

print(min(zeroNum, oneNum) * 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()
counter = 0
length = len(s)
count0 = s.count('0')
count1 = s.count('1')

print("{}".format(int(length - abs(count0 - count1))))

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

Solution (Python):
a = input()
s = list(a)
s_int = [int(i) for i in s ]
t = len(s_int)
i = 0
c0 = s_int.count(0)
c1 = s_int.count(1)
if c0 > c1:
    print(2*c1)
else:
    print(2*c0)

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

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

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

sa = abs(S.count("0") - S.count("1"))

print(len(S)-sa)

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

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

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

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

print(2*min(one, zero))

Solution (Python):
S = input()

num0 = S.count("0")
num1 = len(S)-num0

print(min(num0,num1)*2)

Solution (Python):
l=list(input())
o=0
z=0
for i in range(len(l)):
    if l[i]=="0":
        z+=1
    elif l[i]=="1":
        o+=1

if z > o:
    print(2*o)
else:
    print(2*z)

Solution (Python):
S=input()
stack=[]
ans=0
for i in range(len(S)):
  if not stack:
    stack.append(S[i])
  elif stack[-1]==S[i]:
    stack.append(S[i])
  else:
    stack.pop()
    ans+=2
print(ans)

Solution (Python):



from collections import Counter
S = input()
c = Counter(S)
print(min(c.get('0', 0), c.get('1', 0)) * 2)

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

Solution (Python):
S = input()
C1 = S.count("0")
C2 = S.count("1")

print(min(C1,C2)*2)

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    c = Counter(S)
    if len(c) != 2:
        return 0
    return min(c.values()) * 2


def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()

Solution (Python):
S = list(input())
zeros = sum([1 if int(x) == 0 else 0 for x in S])
ones = sum([1 if int(x) == 1 else 0 for x in S])

print(min(zeros, ones) << 1)

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

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

print(min(L.count(0),L.count(1))*2)

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

Solution (Python):
from collections import deque
S = deque(input())
S2 = deque([])
counter = 0
flag = True
while True:
    if len(S) == 0:
        break
    s = S.popleft()
    if len(S2) == 0:
            S2.append(s)
            flag = False
            continue
    
    elif s!=S2[-1]:
            S2.pop()
            flag = False
            counter +=2
    else:
        S2.append(s)
    if flag:
        break
print(counter)

Solution (Python):
s = input()
a = [s.count(c) for c in '01']
print(min(a) * 2)

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

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

Solution (Python):
S = input()

count = 0
index = -1

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

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

Solution (Python):
S = input()

r = S.count("0")
b = len(S) - r

result = len(S) - abs(r - b)

print(result)

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

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

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

Solution (Python):
s=input()

stack=[]
for si in s:
    stack.append(si)
    if len(stack) >= 2 and stack[-1] != stack[-2]:
        del stack[-2:]
print(len(s)-len(stack))

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

Solution (Python):
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    S = input_raw[0]

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


if __name__ == '__main__':
    main()

Solution (Python):
s=input()

stack=[]
for si in s:
    stack.append(si)
    if len(stack) >= 2 and stack[-1] != stack[-2]:
        del stack[-1]
        del stack[-1]
print(len(s)-len(stack))

Solution (Python):

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

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

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