Problem:


Score : 300 points

Problem Statement

There are N cubes stacked vertically on a desk.

You are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.

You can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.

At most how many cubes can be removed?

Constraints

1 \leq N \leq 10^5

|S| = N

Each character in S is 0 or 1.

Input

Input is given from Standard Input in the following format:

S

Output

Print the maximum number of cubes that can be removed.

Sample Input 1

0011

Sample Output 1

4

All four cubes can be removed, by performing the operation as follows:

Remove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.

Remove the first and second cubes from the bottom.

Sample Input 2

11011010001011

Sample Output 2

12

Sample Input 3

0

Sample Output 3

0



Sample input:
0011


Sample output:
4

Submission status: Accepted

Solution code:
a = input()
count_0 = 0
count_1 = 0

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

print(min(count_0, count_1) * 2)

Submission status: Accepted

Solution code:
S = list(map(int, list(input())))
l = [None]
ans = 0
for s in S:
    if l[-1] is None:
        l.append(s)
        continue
    if s == l[-1]:
        l.append(s)
    else:
        l.pop()
        ans += 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 2019/07/25

s=input()

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

Submission status: Accepted

Solution code:
s = input()
count = 0

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

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
S = input()

count = 0
for i in range(len(S)):
  if S[i] == "0":
    count += 1
    
print(2*min(count,len(S)-count))

Submission status: Accepted

Solution code:
S = str(input())
zeros = S.count("0")
ones = S.count("1")

print(min(zeros, ones) * 2)

Submission status: Accepted

Solution code:
s = input()
set_ = {'0', '1'}
arr = ['*']
for i in s:
    arr.append(i)
    if set(arr[-2:]) == set_:
        arr.pop()
        arr.pop()

ans = len(s) - len(arr) + 1
print(ans)

Submission status: Accepted

Solution code:
s = input()
set_ = set(['0', '1'])
arr = ['*']
for i in s:
    arr.append(i)
    if set(arr[-2:]) == set_:
        arr.pop()
        arr.pop()

ans = len(s) - len(arr) + 1
print(ans)

Submission status: Accepted

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

c = [s[0]]

for i in range(1,len(s)):
    c.append(s[i])
    if c[len(c)-1] != c[len(c)-2]:
        c.pop(len(c)-1)
        c.pop(len(c)-1)

print(len(s) - len(c))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC 120 C

import re

S = input()

l0 = 0
l1 = 0

for i in range(len(S)):
    if S[i] == '0':
        l0 += 1
    elif S[i] == '1':
        l1 += 1

print(min(l0, l1) * 2)

Submission status: Accepted

Solution code:
s = input()
znum = 0
onum = 0
for i in s:
  if i == "0":
    znum+=1
  else:
    onum+=1

print(2*min(znum,onum))

Submission status: Accepted

Solution code:
from collections import Counter
s = input()
cnt = Counter(s)
if len(cnt) == 1:
    print(0)
else:
    print(min(cnt.values()) * 2)

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
data = []
for i in s:
    data.append(int(i))
one = 0
zero = 0
for i in range(len(data)):
    if data[i] == 0:
        zero += 1
    else:
        one += 1

print(min(zero, one) * 2)

Submission status: Accepted

Solution code:
s = input()

counter={'0':0,'1':0}
for si in s:
  counter[si]+=1

diff = abs(counter['0']-counter['1'])

if diff ==0:
  print(len(s))
else:
  print(len(s) - diff)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = [int(x) for x in str(input())]
ones = sum(S)
zeros = len(S)-ones
print(min(ones,zeros)*2)

Submission status: Accepted

Solution code:
s = list(map(int, input()))
s.sort()
sum_s = sum(s)
print(min(sum_s, len(s) - sum_s) * 2)

Submission status: Accepted

Solution code:
s=input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
S = input()
count_01 = Counter(S)
print(len(S)-abs(count_01['1']-count_01['0']))

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = input()
char_count = {"0": 0, "1": 0}
for s in S:
    char_count[s] += 1
print(2 * min(char_count.values()))

Submission status: Accepted

Solution code:
import sys
import math
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    S = inputs[0]
    count_0 = 0
    count_1 = 0

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

    return len(S) - abs(count_0 - count_1)


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Accepted

Solution code:
a = input()
b = len(a) - len(a.replace("1", ""))
c = len(a) - len(a.replace("0", ""))
print(min(b, c)*2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
print(min(s.count(c) for c in '01') * 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
deq=deque()
s=input()
n=len(s)
for i in s:
    if len(deq)==0:
        deq.append(i)
        continue
    x=deq.pop()
    if x==i:
        deq.append(x)
        deq.append(i)
print(n-len(deq))

Submission status: Accepted

Solution code:
S = input()
n0 = 0
n1 = 0
for si in S:
    if si == "0":
        n0 += 1
    else:
        n1 += 1
print(2*min(n0,n1))

Submission status: Accepted

Solution code:
S = input()
lst = []
cnt = 0
for i in range(0, len(S)):
	if lst == []:
		lst.append(S[i])
	elif lst[-1] != S[i]:
		cnt += 2
		lst.pop(-1)
	else:
		lst.append(S[i])
print(cnt)

Submission status: Accepted

Solution code:
S = input()

N = len(S)

cnt_zero = 0
for i in range(N):
  if S[i] == '0':
    cnt_zero += 1
if cnt_zero <= N - cnt_zero:
  print(cnt_zero*2)
else:
  print((N-cnt_zero)*2)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

s = list(input())
s_len = len(s)
arr = []
ctr = 0

for i in range(s_len):
    if arr == [] or s[i] == arr[-1]:
        arr.append(s[i])
    else:
        ctr += 2
        arr.pop()
print(ctr)

Submission status: Accepted

Solution code:
S = list(input())


zero = 0
one = 0
for i in S:
    if i == '0':
        zero += 1
    if i == '1':
        one += 1

ans = min(zero, one) * 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():

    """ convenient functions
    # for i, a in enumerate(iterable)
    # q, mod = divmod(a, b)
    # divmod(x, y) returns the tuple (x//y, x%y)
    # Higher-order function: reduce(operator.mul, xyz_count, 1)
    # manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc127_f
    """

    """convenient decorator
    # @functools.lru_cache():
    # to facilitate use of recursive function
        # ex:
        # from functools import lru_cache
        # import sys
        # sys.setrecursionlimit(10**9)
        # @lru_cache(maxsize=None)
        # def fib(n):
        #     if n < 2:
        #         return n
        #     return fib(n-1) + fib(n-2)
        # print(fib(1000))
    """
    
    # import numpy as np
    import sys
    sys.setrecursionlimit(10**7)
    from itertools import accumulate, combinations, permutations, product # https://docs.python.org/ja/3/library/itertools.html
    # accumulate() returns iterator! to get list: list(accumulate())
    from math import factorial, ceil, floor, sqrt
    def factorize(n):
        """return the factors of the Arg and count of each factor
        
        Args:
            n (long): number to be resolved into factors
        
        Returns:
            list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)]
        """
        fct = []  # prime factor
        b, e = 2, 0  # base, exponent
        while b * b <= n:
            while n % b == 0:
                n = n // b
                e = e + 1
            if e > 0:
                fct.append((b, e))
            b, e = b + 1, 0
        if n > 1:
            fct.append((n, 1))
        return fct
    def combinations_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        # TODO: How should I do when n - r is negative?
        if n < 0 or r < 0:
            raise Exception('combinations_count(n, r) not defined when n or r is negative')
        if n - r < r: r = n - r
        if r < 0: return 0
        if r == 0: return 1
        if r == 1: return n
        numerator = [n - r + k + 1 for k in range(r)]
        denominator = [k + 1 for k in range(r)]
        for p in range(2,r+1):
            pivot = denominator[p - 1]
            if pivot > 1:
                offset = (n - r) % p
                for k in range(p-1,r,p):
                    numerator[k - offset] /= pivot
                    denominator[k] /= pivot
        result = 1
        for k in range(r):
            if numerator[k] > 1:
                result *= int(numerator[k])
        return result
    def combinations_with_replacement_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items allowing individual elements to be repeated more than once.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        if n < 0 or r < 0:
            raise Exception('combinations_with_replacement_count(n, r) not defined when n or r is negative')
        elif n == 0:
            return 1
        else:
            return combinations_count(n + r - 1, r)
    from bisect import bisect_left, bisect_right
    from collections import deque, Counter, defaultdict # https://docs.python.org/ja/3/library/collections.html#collections.deque
    from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest # https://docs.python.org/ja/3/library/heapq.html
    from copy import deepcopy, copy # https://docs.python.org/ja/3/library/copy.html
    import operator
    from operator import itemgetter
    # ex1: List.sort(key=itemgetter(1))
    # ex2: sorted(tuples, key=itemgetter(1,2))
    from functools import reduce, lru_cache
    def chmin(x, y):
        """change minimum
        if x > y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current minimum value
            y (long): potential minimum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x > y:
            x = y
            return (x, True)
        else:
            return (x, False)
    def chmax(x, y):
        """change maximum
        if x < y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current maximum value
            y (long): potential maximum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x < y:
            x = y
            return (x, True)
        else:
            return (x, False)

    from fractions import gcd # Deprecated since version 3.5: Use math.gcd() instead.
    def gcds(numbers):
        return reduce(gcd, numbers)
    def lcm(x, y):
        return (x * y) // gcd(x, y)
    def lcms(numbers):
        return reduce(lcm, numbers, 1)

    # first create factorial_list
    # fac_list = mod_factorial_list(n)
    INF = 10 ** 18
    MOD = 10 ** 9 + 7
    modpow = lambda a, n, p = MOD: pow(a, n, p) # Recursive function in python is slow!
    def modinv(a, p = MOD):
        # evaluate reciprocal using Fermat's little theorem:
        # a**(p-1) is identical to 1 (mod p) when a and p is coprime
        return modpow(a, p-2, p)
    def modinv_list(n, p = MOD):
        if n <= 1:
            return [0,1][:n+1]
        else:
            inv_t = [0,1]
            for i in range(2, n+1):
                inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
            return inv_t
    def modfactorial_list(n, p = MOD):
        if n == 0:
            return [1]
        else:
            l = [0] * (n+1)
            tmp = 1
            for i in range(1, n+1):
                tmp = tmp * i % p
                l[i] = tmp
            return l
    def modcomb(n, k, fac_list = [], p = MOD):
        # fac_list = modfactorial_list(100)
        # print(modcomb(100, 5, modfactorial_list(100)))
        from math import factorial
        if n < 0 or k < 0 or n < k: return 0
        if n == 0 or k == 0: return 1
        if len(fac_list) <= n:
            a = factorial(n) % p
            b = factorial(k) % p
            c = factorial(n-k) % p
        else:
            a = fac_list[n]
            b = fac_list[k]
            c = fac_list[n-k]
        return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p
    def modadd(a, b, p = MOD):
        return (a + b) % MOD
    def modsub(a, b, p = MOD):
        return (a - b) % p
    def modmul(a, b, p = MOD):
        return ((a % p) * (b % p)) % p
    def moddiv(a, b, p = MOD):
        return modmul(a, modpow(b, p-2, p))

    """ initialize variables and set inputs
    # initialize variables
        # to initialize list, use [0] * n
        # to initialize two dimentional array, use [[0] * N for _ in range(N)]
    # set inputs
        # open(0).read() is a convenient method:
        # ex) n, m, *x = map(int, open(0).read().split())
        #     min(x[::2]) - max(x[1::2])
        # ex2) *x, = map(int, open(0).read().split())
        #     don't forget to add comma after *x if only one variable is used
    # preprocessing
        # transpose = [x for x in zip(*data)]
        # ex) [[1, 2, 3], [4, 5, 6], [7, 8, 9]] => [(1, 4, 7), (2, 5, 8), (3, 6, 9)]
        # flat = [flatten for inner in data for flatten in inner]
        # ex) [[1, 2, 3], [4, 5, 6], [7, 8, 9]] => [1, 2, 3, 4, 5, 6, 7, 8, 9]
    # calculate and output
        # output pattern
        # ex1) print(*l) => when l = [2, 5, 6], printed 2 5 6
    """

    # functions used
    r = lambda: sys.stdin.readline().strip()
    r_int = lambda: int(r())
    R = lambda: list(map(int, r().split()))
    Rmap = lambda: map(int, r().split())
    Rfloat = lambda: list(map(float, r().split()))
    Rtuple = lambda: tuple(map(int, r().split()))

    """ how to treat input
    # single int: int(r())
    # single string: r()
    # single float: float(r())
    # line int: R()
    # line string: r().split()
    # line (str, int, int): [j if i == 0 else int(j) for i, j in enumerate(r().split())]
    # lines int: [R() for _ in range(n)]
    """

    if __name__ != '__main__':
        # for test
        sys.stdin = open('sample.txt')

    # ----------------------------------
    # main

    S = r()
    zero = S.count('0')
    one = S.count('1')
    print(len(S)-abs(zero-one))
    
    # N, M = R()
    # AB = [R() for _ in range(N)]
    # AB.sort()
    # ans = 0
    # for a, b in AB:
    #     if M - b > 0:
    #         ans += a*b
    #         M -= b
    #     else:
    #         ans += a*M
    #         M = 0
    #     if M == 0:
    #         print(ans)
    #         exit()
    
    # end of main
    # ----------------------------------

    """memo: how to use defaultdict of list
    # initialize
    Dic = defaultdict(list)
    # append / extend
    Dic[x].append(y)
    # for
    for k, v in Dic.items():
    """

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    s = [int(x) for x in input()]
    n_ones = sum(s)
    print(2 * min(n_ones, len(s) - n_ones))


main()

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = input()
tmp = ''

ret = 0
for s in S:
    if len(tmp) and tmp[-1] != s:
        ret += 1
        tmp = tmp[:-1]
    else:
        tmp += s

print(ret * 2)

Submission status: Accepted

Solution code:
S=list(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

S = input()

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

Submission status: Accepted

Solution code:
s = input()
zero = len([x for x in s if x == "0"])
one = len(s) - zero

print(min(zero, one) * 2)

Submission status: Accepted

Solution code:
s = list(input())
n = len(s)
s.sort()
#print(n,s)
num_0 = 0
num_1 = 0
for i in range(n):
    if s[i] == "1":
        num_0 = i
        break
num_1 = n - num_0
#print(num_0,num_1)

ans = 2*min(num_0,num_1)
print(ans)

Submission status: Accepted

Solution code:
s = input()
a = []
ans = 0
rev = {'0':'1', '1':'0'}
for c in s:
  if a and a[-1] == rev[c]:
    ans += 1
    a.pop()
  else:
    a.append(c)
print(ans * 2)

Submission status: Accepted

Solution code:
s = input()

ans = 0
c = '?'
x = 0
for i in range(len(s)):
    if c == '?':
        c = s[i]
        x = 1
    elif c != s[i]:
        x -= 1
        ans += 2
        if x == 0:
            c = '?'
    else:
        x += 1

print(ans)

Submission status: Accepted

Solution code:
def main():

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input()
b = len(a) - len(a.replace("0", ""))
c = len(a) - len(a.replace("1", ""))
print(min(b, c) * 2)

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
import collections
li = [i for i in S]
if len(list(set(li))) == 2:
    d = collections.Counter(li)
    print(2*min(d["0"],d["1"]))
else:
    print(0)

Submission status: Accepted

Solution code:
from collections import deque
r=deque(map(int,list(input())))
l=deque()
cnt=0
while len(r)>0:
	if len(l)==0:
		l.append(r.popleft())
	if len(r)==0:
		break
	if l[-1] + r[0]==1:
		l.pop()
		r.popleft()
		cnt += 2
	else:
		l.append(r.popleft())
		
print(cnt)

Submission status: Accepted

Solution code:
S = list(input())

a = S.count('0')
b = S.count('1')
m = min(a, b)

print(2 * m)

Submission status: Accepted

Solution code:
S = input()
s = ['01', '10']
 
ans = 0
count = len(S)
i = 0
while count >= 2:
    if S[i:i + 2] in s:
        S = S[:i] + S[i + 2:]
        ans += 2
        count -= 1
        i -= 1
    else:
        i += 1
        count -= 1
 
print(ans)

Submission status: Accepted

Solution code:
#取り去る順番は考えなくてもok、（０と１の数が少ない方）回だけ取り除く動作ができるので、取り除けるキューブ数は（０と１の数が少ない方）＊2個
S = input()
numofzero = 0
numofone = 0
N = len(S)
for i in range(N):
    if S[i] == "0":
        numofzero += 1
    else:
        numofone += 1
if numofone > numofzero:
    print(numofzero*2)
else:
    print(numofone*2)

Submission status: Accepted

Solution code:
S = input()
numofzero = 0
numofone = 0
N = len(S)
for i in range(N):
    if S[i] == "0":
        numofzero += 1
    else:
        numofone += 1
if numofone > numofzero:
    print(numofzero*2)
else:
    print(numofone*2)

Submission status: Accepted

Solution code:
S = input()
blue = 0
red = 0
start = len(S)
for i in range(start):
  if S[i] == '0':
    red += 1
  elif S[i] == '1':
    blue += 1

block = min(red,blue)

print(2*block)

Submission status: Accepted

Solution code:
S = input()
s = ['01', '10']

ans = 0
count = len(S)
i = 0
while count >= 2:
    # 削除できる場合、2文字削除し基準点iはそのままとする
    if S[i:i + 2] in s:
        S = S[:i] + S[i + 2:]
        ans += 2
        count -= 1
        i -= 1
    # 削除できない場合
    else:
        i += 1
        count -= 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    bit = list(sys.stdin.readline().rstrip())
    print(2 * min(bit.count("0"), bit.count("1")))

Submission status: Accepted

Solution code:
S=list(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)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
cnt = []
cnt.append(s.count('0'))
cnt.append(s.count('1'))

print(2 * min(cnt))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
c0 = 0
c1 = 0
for i in range(len(s)):
    if s[i] == "1":
        c1 += 1
    else:
        c0 += 1

if len(s) == 1:
    print(0)
else:
    print(min(c0, c1) * 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
len=len(S)
R=0
B=0
for i in range(len):
    if S[i]=='0':
        R+=1
    else:
        B+=1

print(len-abs(R-B))

Submission status: Accepted

Solution code:
import numpy as np
import math


s = input()

count_1 = 0
count_0 = 0

for c in s:
    if c == '1':
        count_1 += 1
    if c == '0':
        count_0 += 1

print(2* min(count_0, count_1))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
c0, c1 = 0, 0
for i in range(len(S)):
    if S[i] == '0':
        c0 += 1
    else:
        c1 += 1

print(2*min(c0, c1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

a = s.count("0")
print(min(a, len(s) - a) * 2)

Submission status: Accepted

Solution code:
# 最後までいける

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
S = str(input())

#(S[i - 1] == '1' and S[i] == '0') or (S[i - 1] == '0' and S[i] == '1')

S_dict = {}
if len(S) == 1:
    print(0)
    sys.exit()

for letter in S:
    if letter == '1':
        if letter in S_dict:
            S_dict[letter] += 1
        else:
            S_dict[letter] = 1
    elif letter == '0':
        if letter in S_dict:
            S_dict[letter] += 1
        else:
            S_dict[letter] = 1

if len(S_dict.values()) == 1:
    print(0)
    sys.exit()
print(min(S_dict.values()) * 2)

Submission status: Accepted

Solution code:
s = [i for i in input()]
one,zero = [0],[0]
for i in range(len(s)):
    if s[i] == '1': one.append(one[i]+1)
    else:   one.append(one[i])
    if s[i] == '0': zero.append(zero[i]+1)
    else:   zero.append(zero[i])
print(min(one[-1],zero[-1])*2)

Submission status: Accepted

Solution code:
S = list(input())
a = S.count("0")
b = S.count("1")
if a == b:
    print(a * 2)
elif a > b:
    print(b * 2)
elif a < b:
    print(a * 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s1 = input()

r1 = 0
b1 = 0

for i1 in range(len(s1)):
    if s1[i1] == "0":
        r1 += 1
    else:
        b1 += 1

print(min(r1, b1) * 2)

Submission status: Accepted

Solution code:
s = input()
s1 = []
for i in range(len(s)):
    s1.append(s[i])
print(min(s1.count("1"), s1.count("0"))*2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

s0 = s.count("0")
s1 = s.count("1")
#print(s0)
#print(s1)
print(len(s)-(max(s0,s1)-min(s0,s1)))

Submission status: Accepted

Solution code:
S = list(input())
N = len(S)
count0 = 0
for i in range(N):
    if S[i] == '0':
        count0 += 1        
count1 = N - count0
print(2 * min(count0,count1))

Submission status: Accepted

Solution code:
# 最終形態は000..か1111...しかないのでそれぞれ数えて小さい方*2
s = input()
one, zero = 0, 0
for sv in s:
    if sv == "0":
        zero += 1
    else:
        one += 1
print(min(zero, one)*2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=list(map(int,list(input())))
Snew=[-1]
for i in S:
    if Snew[-1]==i or Snew[-1]==-1:
        Snew.append(i)
    else:Snew.pop()
print(len(S)-len(Snew)+1)

Submission status: Accepted

Solution code:
s = list(input())
red = 0
blue = 0

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

Submission status: Accepted

Solution code:
a = input()

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

Submission status: Accepted

Solution code:
s = list(input())
red = s.count("0")
blue = s.count("1")

print(len(s)-abs(red-blue))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

print(min(c0,c1)*2)

Submission status: Accepted

Solution code:
s=input()
orig = len(s)
ones = sum([1 for x in s if x == '1'])
zeros = sum([1 for x in s if x == '0'])
print(2*min(ones, zeros))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=input()
a=N.count("0")
b=N.count("1")
if a==0 or b ==0:
  print(0)
elif a>=b:
  print(2*b)
else:
  print(2*a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
z = S.count("0")
o = S.count("1")

print(min(z, o) * 2)

Submission status: Accepted

Solution code:
S = input()

zero = 0
one = 0

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

print(min(zero, one) * 2)

Submission status: Accepted

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

print(len(S)-abs(cnt0-cnt1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(map(int,input()))
i=0
ans=0

s=[s.count(0),s.count(1)]
print(min(s)*2)

Submission status: Accepted

Solution code:
S = input()
N = len(str(S))
cubes = [int(i) for i in list(S)]

one_count = len([i for i in cubes if i == 1])

if one_count > N - one_count:
  print(2 * (N - one_count))
else: 
  print(2 * one_count)