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()
N = len(S)
num_one = S.count('1')
num_zero = S.count('0')
print(N - abs(num_one - num_zero))

Solution (Python):
S = input()

zero = 0
one = 0
for s in S:
    if s == '0':
        zero += 1
    if s == '1':
        one += 1
    
print(len(S) - abs(zero - one))

Solution (Python):
s = input()

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

print(min(count0,count1) * 2)

Solution (Python):
S = input()

S = list(S)
ones = S.count("1")
zeors = S.count("0")

print(min(ones, zeors) * 2)

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

Solution (Python):
s = input()

one = 0
zero = 0
for i in range(len(s)):
    if s[i] == "0":
        zero += 1
    else:
        one += 1

a = min(zero, one)

print(2 * a)

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

prev = ""
index = 0
ans = 0
while index < len(S):

    if prev == "":
        prev = S[index]
        index = index + 1
        continue

    if S[index] != prev:
        S.pop(index)
        S.pop(index - 1)
        ans = ans + 2
        if len(S) == 0:
            break

        index = index - 2 if index - 2 > 0 else 0
        prev = ""

    else:
        prev = S[index]
        index = index + 1

print(ans)

Solution (Python):
import numpy as np
s = [int(i) for i in input()]
array = np.array(s)
zero = np.sum(array==0)
one = np.sum(array==1)
print(2*min(zero,one))

Solution (Python):
if __name__ == '__main__':
    string = input()
    zero_count = string.count('0')
    one_count = string.count('1')
    print(min(zero_count, one_count) * 2)

Solution (Python):
S = input()

C0 = S.count("0")
C1 = S.count("1")

print(2*min(C0,C1))

Solution (Python):
s=input()
a_1=s.count("1")
b_1=s.count("0")
if a_1<=b_1:
  print(2*a_1)
else:
  print(2*b_1)

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

Solution (Python):
s=input()
a_1=s.count("1")
b_1=s.count("0")
if a_1<=b_1:
  print(2*a_1)
else:
  print(2*b_1)

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

s = S

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

zero_one_diff = max(zero, one) - min(zero, one)
print(len(s) - zero_one_diff)

Solution (Python):
s = input()

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

print(2 * min(zero, one))

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

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

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

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

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

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

Solution (Python):
S = input()
red_count = S.count("0")
ao_count = S.count("1")
if red_count > ao_count:
    print(ao_count * 2)
elif red_count < ao_count:
    print(red_count * 2)
else:
    print(red_count + ao_count)

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

Solution (Python):
s = input()

red_count = s.count('0')
blue_count = s.count('1')

print(min(red_count,blue_count) * 2)

Solution (Python):
S = input()

remove_count = 0








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

Solution (Python):
S = input()

redcount = S.count('0')
bluecount = S.count('1')

mincount = min(redcount,bluecount)
answer = mincount*2

print(answer)

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

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

Solution (Python):
import sys, math
from collections import Counter

stdout_write = sys.stdout.write

for line in sys.stdin:
  s = Counter(list(line.strip()))
  ans = 2 * min(s['0'], s['1'])
  stdout_write('{}\n'.format(ans))

Solution (Python):
n = list(str(input()))
a = n.count("1")
b = n.count("0")

c = min(a,b)

print(2 * c)

Solution (Python):
n = list(str(input()))
a = 0
b = 0
for i in n:
    if i == "1":
        a += 1
    else:
        b += 1

c = min(a,b)

print(2 * c)

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

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

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

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

S_1 = int(S.count('1'))
S_0 = int(S.count('0'))

if S_1 > S_0:
    print S_0 * 2
else:
    print S_1 * 2

Solution (Python):
S = input()
num_length = len(S)
counter_0 = 0
counter_1 = 0
for i in range(num_length):
    if S[i] == '0':
        counter_0 += 1
    if S[i] == '1':
        counter_1 += 1
if counter_0 <= counter_1:
    print(2*counter_0)
else:
    print(2*counter_1)

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

Solution (Python):
s = str(raw_input())
c0 = s.count('0')
c1 = len(s) - c0
print 2 * min(c0, c1)

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

zero_num = S.count("0")

print(2*min(zero_num, len(S) - zero_num))

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

zero_num = 0

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

print(2*min(zero_num, len(S) - zero_num))

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

zero_num = 0
one_num = 0

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

print(2*min(zero_num, one_num))

Solution (Python):
S = input()

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

ans = min(a,b)
print(2*ans)

Solution (Python):
s = str(input())
cntz = 0
cnto = 0
for i in s:
    if i == '0':
        cntz += 1
    elif i == '1':
        cnto += 1
ans = 2*min(cnto,cntz)
print(ans)

Solution (Python):
S = input()

red = S.count('0')
blue = S.count('1')
N = 2 * min(red,blue)

print(N)

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

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

Solution (Python):
def smaller(x, y):
	if x < y: return x
	else: return y

S = raw_input()
count = [0, 0]
for i in range(0, len(S)):
	count[int(S[i])] += 1

print smaller(count[0], count[1])*2

Solution (Python):
s = input()

_1 = s.count("1")
_0 = s.count("0")

m = min(_1, _0)

print(m*2)

Solution (Python):

import sys


def solve(S: str):
    c0 = 0
    c1 = 0
    for c in S:
        if c == "0":
            c0 += 1
        else:
            c1 += 1
    print(min(c0,c1) * 2)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  
    solve(S)

if __name__ == '__main__':
    main()

Solution (Python):
def solve(s):
    pos_num, neg_num = 0, 0
    for string in s:
        if string == "1":
            pos_num += 1
        else:
            neg_num += 1

    return 2 * min(pos_num, neg_num)


def main():
    s = input()

    ans = solve(s)
    print(ans)


main()

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

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



Red = S.count("0")
Blue = S.count("1")



if Red > Blue:
    result = Blue*2
else:
    result = Red*2

print(result)

Solution (Python):
s = input()

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

print(min(cnt1,cnt2)*2)

Solution (Python):
s = input()

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

print(2 * (r if r < b else b))

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

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

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

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

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

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

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

print(min(cnt0,cnt1)*2)

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

Solution (Python):
S = input()
N = len(S)
count0 = 0
count1 = 0
for c in S:
    if c == "0":
        count0 += 1
    else:
        count1 += 1
print(N - abs(count0 - count1))

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

Solution (Python):
S = input()

red = S.count('0')
blue = S.count('1')

print(min(red, blue)*2)

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

Solution (Python):


def solve():
    S = input()

    ans = 0
    i = 0
    while i != len(S):
        if i+1 >= len(S):
            break

        if S[i] != S[i+1]:
            
            if i == 0:
                if len(S) <= 2:
                    ans += 1
                    S = ""
                    continue
                else:
                    ans += 1
                    S = S[2:]
                    continue
            else:
                if i+2 < len(S):
                    ans += 1
                    S = S[:i] + S[i+2:]
                    i -= 1
                    continue
                else:
                    ans += 1
                    S = S[:i]
                    i -= 1
                    continue
            
        i += 1
    print(ans*2)


if __name__ == "__main__":
    solve()

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

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

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

tmp_i = 0
while len(S) > 1:
    no_01 = True
    before_s = None
    for i, s in enumerate(S[tmp_i:]):
        if i == 0:
            before_s = s
            continue
        if before_s != s:
            no_01 = False
            
            newS = S[:tmp_i + i-1] + S[tmp_i + i+1:]
            S = newS
            
            tmp_i = tmp_i + i - 2
            if tmp_i < 0:
                tmp_i = 0
            
            break
    if no_01:
        break
print(init_count - len(S))

Solution (Python):
S = input()

red = S.count('0')
blue = S.count('1')

print(2*(min(red, blue)))

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

Solution (Python):
S = input()
N, counter_zero, counter_one = len(S), 0, 0
for i in range(N):
    if S[i:i+1] == '0':
        counter_zero += 1
    elif S[i:i+1] == '1':
        counter_one += 1
ans = 2 * min(counter_zero, counter_one)
print(ans)

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

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

Solution (Python):
S = input()

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

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

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

Solution (Python):
string = input()

zeros = string.count('0')
ones = string.count('1')

print(min(zeros,ones)*2)

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

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

Solution (Python):
s = input()

red_count = s.count('0')
blue_count = s.count('1')

print(min(red_count,blue_count) * 2)

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

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

Solution (Python):
S = input()


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

Solution (Python):
S = list(input())
one_num = S.count('1')
zero_num = S.count('0')

if one_num == zero_num:
    print(len(S))
else:
    print(len(S) - abs(one_num - zero_num))

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

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

cnt = 0
i = 1
while True:
	
	if i >= len(ss):
		break
	if ss[i-1] != ss[i]:
		ss.pop(i-1)
		ss.pop(i-1)
		cnt += 2
		if i > 1:
			i -= 1
	else:
		i += 1

print(cnt)

Solution (Python):

from collections import defaultdict
from collections import deque
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] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    s = S()
    n = len(s)
    d = deque([s[0]])
    l = deque()
    for i in range(1,n):
        if d[0] != s[i]:
            l.append(d)
            d = deque(s[i])
        else:
            d.append(s[i])
    if d:l.append(d)
    while len(l) > 1:
        x = l.popleft()
        y = l.popleft()
        if x[0] == y[0]:
            for i in range(len(y)):
                x.append(y[0])
            l.appendleft(x)
        else:
            if len(x) == len(y):continue
            if len(x) > len(y):
                for i in range(len(y)):
                    x.pop()
                l.appendleft(x)
            else:
                for i in range(len(x)):
                    y.pop()
                l.appendleft(y)
    if l:
        ans = n-len(l[0])
    else:
        ans = n
    print(ans)
    return


def B():
    n = I()
    h = LI()
    ans = 0
    s = deque()
    k = []
    for i in range(n):
        if h[i] == 0:
            if k:s.append(k)
            k = []
        else:k.append(h[i])
    if k:s.append(k)
    while s:
        k = s.popleft()
        if k == []:continue
        m = min(k)
        ans += m
        for i in range(len(k)):
            k[i] -= m
        l = []
        for i in range(len(k)):
            if k[i] == 0:
                if l:s.append(l)
                l = []
            else:l.append(k[i])
        if l:s.append(l)
    print(ans)
    return


def C():
    n,k = LI()
    x = LI()
    ans = float("inf")
    j = bisect.bisect_left(x,0)
    if n == 1:
        print(abs(x[0]))
        quit()
    if j < n:
        if x[j] == 0:
            k -= 1
            x.pop(j)
            n -= 1
    for i in range(n):
        if i < j:
            if abs(i-j) > k:continue
            elif abs(i-j) == k:ans = min(ans,abs(x[i]))
            elif k+i-1 < n:
                ans = min(ans,abs(x[i])+x[k+i-1]-x[i])
        else:
            if abs(i-j)+1 > k:continue
            elif abs(i-j)+1 == k:ans = min(ans,x[i])
            elif i-k+1 >= 0:
                ans = min(ans,abs(x[i])+x[i]-x[i-k+1])

    print(ans)
    return


def D():
    n = I()
    a = LI()
    ans = 0
    p = [1<<i for i in range(100)]
    for i in range(n):
        l = 0
        r = 100
        while r-l > 1:
            m = (l+r)//2
            if a[i]%p[m] == 0:
                l = m
            else:
                r = m
        ans += l
    print(ans)
    return


def E():
    s = LI()
    s.sort()
    ans = s[2]-s[1]
    s[0] += s[2]-s[1]
    s[1] = s[2]
    if s[0]%2 != s[1]%2:
        ans += (s[1]+1-s[0])//2+1
    else:
        ans += (s[1]-s[0])//2
    print(ans)
    return


def F():
    n = I()
    s = SR(n)
    for i in range(n):
        d = defaultdict(int)
        for j in range(len(s[i])):
            d[s[i][j]] += 1
            s[i][j] += str(d[s[i][j]])
    ans = set(s[0])
    for i in range(1,n):
        ans = ans&set(s[i])
    ans = list(ans)
    ans.sort()
    for i in ans:
        print(i[0],end = "")
    print()
    return


def G():
    s = S()
    ans = 0
    for i in range(len(s)-1):
        if s[i] != s[i+1]:ans += 1
    print(ans)
    return


def H():
    n,q = LI()
    ans = [0 for i in range(n+1)]
    for i in range(q):
        l,r = LI()
        ans[l-1] ^= 1
        ans[r] ^= 1
    for i in range(n):
        ans[i+1] ^= ans[i]
        print(ans[i],end = "")
    print()
    return


def I_():
    n = I()
    a = LI()
    ans = 0
    r = 0
    for l in range(n):
        while r < n-1 and a[r+1] > a[r]:
            r += 1
        ans += r-l+1
        if l==r:r += 1
    print(ans)
    return


def J():
    n = I()
    h = LI()
    dp = [float("inf") for i in range(n)]
    dp[0] = 0
    for i in range(n-1):
        dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i]))
        if i < n-2:
            dp[i+2] =  min(dp[i+2],dp[i]+abs(h[i+2]-h[i]))
    print(dp[n-1])
    return


if __name__ == "__main__":
    A()

Solution (Python):

from collections import defaultdict
from collections import deque
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] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    s = S()
    n = len(s)
    d = deque([s[0]])
    l = deque()
    for i in range(1,n):
        if d[0] != s[i]:
            l.append(d)
            d = deque(s[i])
        else:
            d.append(s[i])
    if d:l.append(d)
    while len(l) > 1:
        x = l.popleft()
        y = l.popleft()
        if x[0] == y[0]:
            for i in range(len(y)):
                x.append(y[0])
            l.appendleft(x)
        else:
            if len(x) == len(y):continue
            if len(x) > len(y):
                for i in range(len(y)):
                    x.pop()
                l.appendleft(x)
            else:
                for i in range(len(x)):
                    y.pop()
                l.appendleft(y)
    if l:
        ans = n-len(l[0])
    else:
        ans = n
    print(ans)
    return


def B():
    n = I()
    h = LI()
    ans = 0
    s = deque()
    k = []
    for i in range(n):
        if h[i] == 0:
            if k:s.append(k)
            k = []
        else:k.append(h[i])
    if k:s.append(k)
    while s:
        k = s.popleft()
        if k == []:continue
        m = min(k)
        ans += m
        for i in range(len(k)):
            k[i] -= m
        l = []
        for i in range(len(k)):
            if k[i] == 0:
                if l:s.append(l)
                l = []
            else:l.append(k[i])
        if l:s.append(l)
    print(ans)
    return


def C():
    n,k = LI()
    x = LI()
    ans = float("inf")
    j = bisect.bisect_left(x,0)
    if n == 1:
        print(abs(x[0]))
        quit()
    if j < n:
        if x[j] == 0:
            k -= 1
            x.pop(j)
            n -= 1
    for i in range(n):
        if i < j:
            if abs(i-j) > k:continue
            elif abs(i-j) == k:ans = min(ans,abs(x[i]))
            elif k+i-1 < n:
                ans = min(ans,abs(x[i])+x[k+i-1]-x[i])
        else:
            if abs(i-j)+1 > k:continue
            elif abs(i-j)+1 == k:ans = min(ans,x[i])
            elif i-k+1 >= 0:
                ans = min(ans,abs(x[i])+x[i]-x[i-k+1])

    print(ans)
    return


def D():
    n = I()
    a = LI()
    ans = 0
    p = [1<<i for i in range(100)]
    for i in range(n):
        l = 0
        r = 100
        while r-l > 1:
            m = (l+r)//2
            if a[i]%p[m] == 0:
                l = m
            else:
                r = m
        ans += l
    print(ans)
    return


def E():
    s = LI()
    s.sort()
    ans = s[2]-s[1]
    s[0] += s[2]-s[1]
    s[1] = s[2]
    if s[0]%2 != s[1]%2:
        ans += (s[1]+1-s[0])//2+1
    else:
        ans += (s[1]-s[0])//2
    print(ans)
    return


def F():
    n = I()
    s = SR(n)
    for i in range(n):
        d = defaultdict(int)
        for j in range(len(s[i])):
            d[s[i][j]] += 1
            s[i][j] += str(d[s[i][j]])
    ans = set(s[0])
    for i in range(1,n):
        ans = ans&set(s[i])
    ans = list(ans)
    ans.sort()
    for i in ans:
        print(i[0],end = "")
    print()
    return


def G():
    s = S()
    ans = 0
    for i in range(len(s)-1):
        if s[i] != s[i+1]:ans += 1
    print(ans)
    return


def H():
    n,q = LI()
    ans = [0 for i in range(n+1)]
    for i in range(q):
        l,r = LI()
        ans[l-1] ^= 1
        ans[r] ^= 1
    for i in range(n):
        ans[i+1] ^= ans[i]
        print(ans[i],end = "")
    print()
    return


def I_():
    n = I()
    a = LI()
    ans = 0
    r = 0
    for l in range(n):
        while r < n-1 and a[r+1] > a[r]:
            r += 1
        ans += r-l+1
        if l==r:r += 1
    print(ans)
    return


def J():
    n = I()
    h = LI()
    dp = [float("inf") for i in range(n)]
    dp[0] = 0
    for i in range(n-1):
        dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i]))
        if i < n-2:
            dp[i+2] =  min(dp[i+2],dp[i]+abs(h[i+2]-h[i]))
    print(dp[n-1])
    return


if __name__ == "__main__":
    A()

Solution (Python):


s = input()

z = s.count("0")
o = s.count("1")

print(2*min(z,o))

Solution (Python):


s = input()

z = s.count("0")
o = s.count("1")

print(2*min(z,o))

Solution (Python):

from collections import defaultdict
from collections import deque
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] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    s = S()
    c = s.count("0")
    print(2*min(c,len(s)-c))
    return


def B():
    return


def C():
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


def I_():
    return


def J():
    return


if __name__ == "__main__":
    A()

Solution (Python):
s = input()
red = s.count('0')
blue = s.count('1')
print((red if red < blue else blue)*2)

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

S2 = S[0]
count = 0
for i in range(1,N):
    S2 += S[i]
    while len(S2) > 1 and S2[len(S2)-1] != S2[len(S2)-2] :
        S2 = S2[:len(S2)-2]
        count += 2
        
print(count)

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

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

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

Solution (Python):
S = input()
i = 0
total = 0
while i < len(S):
    if S[i:i+2] == '01'or S[i:i+2] == '10':
        Sa = S[:i]
        Sb = S[i+2:]
        S = Sa+Sb
        total += 1
        i -= 1
    else:
        i += 1
print(total*2)

Solution (Python):
S = input()
A = S.count('0')
B = len(S) - A
if A > B:
    print(2*B)
elif B > A:
    print(2*A)
else:
    print(A+B)

Solution (Python):
x=0
y=0
for i in list(input()):
  if i=='0':
    x+=1
  else:
    y+=1
print(min(x,y)*2)

Solution (Python):
S = input()
C1 = 0
C0 = 0
for i in range(len(S)):
    if S[i] == '1':
        C1 +=1
    if S[i] == '0':
        C0 +=1

print(min(C0,C1)*2)

Solution (Python):
S = input()

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

print(2 * min(zero, one))

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

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

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

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

Solution (Python):
S = input()

zeroNum = S.count('0')
oneNum = S.count('1')

print(min(zeroNum,oneNum)*2)

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

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

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

	print(total)

if __name__ == '__main__':
    main()

Solution (Python):
from collections import deque

def unification(string):

    n = len(string)

    if n == 1:
        return 0

    q = deque()
    idx = 2
    q.appendleft(string[0])
    q.appendleft(string[1])
    count = 0

    while idx < n:
        while len(q) > 1 and q[0] != q[1]:
            q.popleft()
            q.popleft()
            count += 2

        q.appendleft(string[idx])
        idx += 1

    if len(q) > 1 and q[0] != q[1]:
        q.popleft()
        q.popleft()
        count += 2

    return count


if __name__ == "__main__":
    string = input()
    print(unification(string))

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()
N = len(S)

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

Solution (Python):
def main():

    S = input()
    N = len(S)

    count = 0
    for n in range(N):
        if S[n] == '1':
            count += 1

    print(N - abs(N - 2 * count))


main()

Solution (Python):
S = input()
l = len(S)
if l >=2:
  ones = sum([int(i) for i in S])
  zeros = l - ones
  print(min(ones, zeros) * 2)
else:
  print(0)

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

C0=[]
C1=[]

for n in range(N):
  if S[n]=='0':
    C0.append(n)
  elif S[n]=='1':
    C1.append(n)

C_Num=[len(C0),len(C1)]
print(2*min(C_Num))

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

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

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

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

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

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

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

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

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

count_zero = 0
count_one = 0

for i in range(len(N)):
    if int(N[i]) == 0:
        count_zero += 1
    else:
        count_one += 1
print(min(count_zero, count_one)*2)

Solution (Python):

"""
C - Unification
https://atcoder.jp/contests/abc120/tasks/abc120_c

"""
import sys


def solve(S):
    orig_len = len(S)
    num_value = {'0': -1, '1': 1}
    status = 0

    for s in S:
        status += num_value[s]
        
        
        
        
    return orig_len - abs(status)


def main(args):
    S = input()
    ans = solve(S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
S = input()

red, blue = 0, 0
for s in S:
    if s=='0':
        red += 1
    else:
        blue += 1
ans = len(S) - abs(red-blue)
print(ans)

Solution (Python):
def main():
   S = str(input())
   S_0_num = S.count('0')
   S_1_num = S.count('1')
   if S_0_num > S_1_num:
       print(S_1_num*2)
   else:
       print(S_0_num*2)

main()

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

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

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

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

Solution (Python):
s = input()


num_1 = 0
num_0 = 0
for t in s:
    if t == '1':
        num_1 += 1
    else:
        num_0 += 1


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

Solution (Python):
S = input()

s0 = S.count('0')
s1 = S.count('1')

print(min(s0, s1)*2)

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

Solution (Python):
from sys import stdin


sdi = stdin.readline().rstrip()



l = list(sdi)
l.reverse()
start = len(l)
i = 0
while len(l) - 1 >= i + 1:
    if l[i] != l[i + 1]:
        l.pop(i + 1)
        l.pop(i)
        i = max(i - 2, 0)
        continue
    i += 1
print(start - len(l))

Solution (Python):


import sys
input = sys.stdin.readline

S = input()

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

print(min(zero, one) * 2)

Solution (Python):
S=input()

c0=0

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

if len(S)>c0*2:
    print(2*c0)
else:
    print((len(S)-c0)*2)

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

Solution (Python):
S = input()

s = list(S)

answer = 0
for i in reversed(range(1, len(s))):
    if i >= len(s):
        continue
         
    if s[i] != s[i - 1]:
        s.pop(i - 1)
        s.pop(i - 1)
        answer = answer + 2

print(answer)

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

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

print(min(a,b)*2)

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