CodeEff/ECCO huggingface dataset:
# Original solution
N,K = list(map(int,input().split()))
p = list(map(int,input().split()))
expectation=[]
E = []

#期待値
for t in p:
    value = 0
    for x in range(t+1):
        value += x/t
    E.append(value)

for t in range(N-(K-1)):
    value = 0
    for i in range(K):
        value += E[t+i]
    expectation.append(value)

output = sorted(expectation,reverse=True)
print((format(output[0],'.12f')))

# Optimized solution
N,K = list(map(int,input().split()))
p = list(map(int,input().split()))

E = []
value=0
#期待値の計算,累積和の計算
for P_i in p:
    value += (1+P_i)/2
    E.append(value)

flag = E[K-1]
#隣接するK項の計算
for k in range(K,N):
    S = E[k] - E[k-K]
    if flag < S:
        flag = S
print((format(flag,'.12f')))
# Original solution
import math
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))

INDEX = -1
MA = 0
for i in range((N - K + 1)//2):
    M = 0
    L = 0
    for j in range(K):
        M += P[i + j]
        L += P[-1-i-j]
    # print(L)
    if M > MA:
        MA = M
        INDEX = i
    if L > MA:
        MA = L
        INDEX = N-K-i

ans = 0
for i in range(K):
    ans += P[i+INDEX] * (P[i+INDEX]+1) / (2*P[i+INDEX])

print(("{:.12f}".format(ans)))


# Optimized solution
import math
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))

INDEX = 0
total = 0
for i in range(K):
    total += P[i]

tmp = total
for i in range(N - K):
    tmp = tmp - P[i] + P[i + K]
    
    if tmp > total:
        total = tmp
        INDEX = i+1


# MA = 0
# for i in range(N - K + 1):
#     M = 0
#     for j in range(K):
#         M += P[i + j]
    
#     if M > MA:
#         MA = M
#         INDEX = i

ans = 0
for i in range(K):
    ans += P[i+INDEX] * (P[i+INDEX]+1) / (2*P[i+INDEX])

print(("{:.12f}".format(ans)))
# Original solution
#python3

def f(x):
    return (x+1)/2

def main():
    n, k = list(map(int, input().split()))
    fp = [f(int(i)) for i in input().split()]
    n = len(fp)
    v = sum(fp[0:k])
    i = 0
    ans = v
    while i+k <= n-1:
        v = v-fp[i]+fp[i+k] 
        ans = max(ans, v)
        i+=1

    a = "{0:.12f}".format(ans)
    print(a)

main()


# Optimized solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def E(x):
    return (x*(x+1)//2)/x
def main():
    N, K = list(map(int, readline().split()))
    e = [E(int(i)) for i in readline().split()]
    s = [0.]
    for i in range(N):
        s.append(s[i]+e[i])
    ans = 0.
    for i in range(N-K+1):
        ans = max(s[K+i]-s[i], ans)
    print(('{:.12f}'.format(ans)))
if __name__ == '__main__':
    main()
# Original solution
N,K = list(map(int,input().split()))
p = list(map(int,input().split()))

def exp(n):
    if n % 2 == 0:
        s = (n+1)*n/2
    else:
        s = (n+1)*(n-1)/2+(n+1)/2
    ans = s / n
    return ans

M = 0
for i in range(N-K+1):
    S = 0
    for j in range(K):
        S += exp(p[i+j])
    if M < S:
        M = S

print(('{:.12f}'.format(M)))

# Optimized solution
N,K = list(map(int,input().split()))
p = list(map(int,input().split()))

def exp(n):
    if n % 2 == 0:
        s = (n+1)*n/2
    else:
        s = (n+1)*(n-1)/2+(n+1)/2
    ans = s / n
    return ans

q = []
for i in range(N):
    q.append(exp(p[i]))
#print(q)

S = sum([q[i] for i in range(K)])
M = S
#print(M)

for i in range(N-K):
    S = S - q[i] + q[K+i]
    #print(S)
    if S > M:
        M = S

print(('{:.12f}'.format(M)))
# Original solution
import sys
input = sys.stdin.readline

"""
後ろから、到達不可能距離の集合を見ていきたい。
集合を持つと厳しいが、最小値だけ持っておけばよい。
"""

N,dist = list(map(int,input().split()))
D = [int(x) for x in input().split()]

# 各ターンの出発位置
start_dist = [dist]
for d in D:
    x = start_dist[-1]
    y = min(abs(x - d), x)
    start_dist.append(y)

ng_dist = [None] * (N+1)
ng_dist[N] = 1

for i,d in enumerate(D[::-1]):
    x = ng_dist[N-i]
    y = x if x <= d//2 else x + d
    ng_dist[N-i-1] = y

eval(input())
Q = [int(x) for x in input().split()]

answer = ['YES' if ng_dist[d] <= start_dist[d-1] else 'NO' for d in Q]

print(('\n'.join(answer)))

# Optimized solution
import sys
input = sys.stdin.readline

"""
後ろから、到達不可能距離の集合を見ていきたい。
集合を持つと厳しいが、最小値だけ持っておけばよい。
"""

N,dist = list(map(int,input().split()))
D = [int(x) for x in input().split()]

# 各ターンの出発位置
start_dist = [dist]
for d in D:
    x = start_dist[-1]
    y = x-d if x > d else d - x
    start_dist.append(x if x < y else y)

ng_dist = [None] * (N+1)
ng_dist[N] = 1

for i,d in enumerate(D[::-1]):
    x = ng_dist[N-i]
    y = x if x <= d//2 else x + d
    ng_dist[N-i-1] = y

eval(input())
Q = [int(x) for x in input().split()]

answer = ['YES' if ng_dist[d] <= start_dist[d-1] else 'NO' for d in Q]

print(('\n'.join(answer)))
# Original solution
N, D = list(map( int, input().split() ))
d = list( map( int, input().split() ) )
Q = int( eval(input()) )
q = list( map( int, input().split() ) )

dis = [ 0 for i in range( N + 1 ) ]
dis[ 0 ] = D
for i in range( N ):
  dis[ i + 1 ] = min( dis[ i ], abs( dis[ i ] - d[ i ] ) )

dp = [ 0 for i in range( N + 1 ) ]
dp[ N ] = 1
for i in range( N - 1, -1, -1 ):
  if dp[ i + 1 ] <= d[ i ] // 2:
    dp[ i ] = dp[ i + 1 ]
  else:
    dp[ i ] = dp[ i + 1 ] + d[ i ]

for qi in range( Q ):
  print(( [ "NO", "YES" ][ dis[ q[ qi ] - 1 ] >= dp[ q[ qi ] ] ] ))


# Optimized solution
N, D = list(map( int, input().split() ))
d = list( map( int, input().split() ) )
Q = int( eval(input()) )
q = list( [int( x ) - 1 for x in input().split()] )

dis = [ 0 for i in range( N + 1 ) ]
dis[ 0 ] = D
for i in range( N ):
  dis[ i + 1 ] = min( dis[ i ], abs( dis[ i ] - d[ i ] ) )

dp = [ 0 for i in range( N + 1 ) ]
dp[ N ] = 1
for i in range( N - 1, -1, -1 ):
  if dp[ i + 1 ] <= d[ i ] // 2:
    dp[ i ] = dp[ i + 1 ]
  else:
    dp[ i ] = dp[ i + 1 ] + d[ i ]

for qi in range( Q ):
  print(( [ "NO", "YES" ][ dis[ q[ qi ] ] >= dp[ q[ qi ] + 1 ] ] ))
# Original solution
n, D = list(map(int, input().split()))
x = list(map(int, input().split()))
Q = int(eval(input()))
q = list(map(int, input().split()))

ind = [D]
for i in range(n):
	ind.append(min(ind[-1], abs(ind[-1] - x[i])))
#print(ind)

l = [1]
for i in range(n-1, -1, -1):
	if x[i] < 2*l[-1]:
		l.append(x[i] + l[-1])
	else:
		l.append(l[-1])
l = l[::-1]

for i in range(Q):
	if l[q[i]] <= ind[q[i]-1]:
		print("YES")
	else:
		print("NO")

# Optimized solution
n, D = list(map(int, input().split()))
x = list(map(int, input().split()))
Q = int(eval(input()))
q = list(map(int, input().split()))

ind = [D]
for i in range(n):
	ind.append(min(ind[-1], abs(ind[-1] - x[i])))

l = [1]
for i in range(n-1, -1, -1):
	if x[i] < 2*l[-1]:
		l.append(x[i] + l[-1])
	else:
		l.append(l[-1])
l = l[::-1]

for i in range(Q):
	if l[q[i]] <= ind[q[i]-1]:
		print("YES")
	else:
		print("NO")
# Original solution
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
day = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
day = day[::-1]
i = day.index(S)
print((i+1))



# Optimized solution
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
days = 'SUN,MON,TUE,WED,THU,FRI,SAT'.split(',')
day_to_x = {x: 7 - i for i, x in enumerate(days)}

print((day_to_x[S]))
# Original solution
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    d = collections.defaultdict(int)
    d["SUN"] = 7
    d["MON"] = 6
    d["TUE"] = 5
    d["WED"] = 4
    d["THU"] = 3
    d["FRI"] = 2
    d["SAT"] = 1
    print((d[str(readline().rstrip().decode('utf-8'))]))


if __name__ == '__main__':
    solve()


# Optimized solution
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    d = {v: 7 - i for i, v in enumerate("SUN,MON,TUE,WED,THU,FRI,SAT".split(","))}
    print((d[str(readline().rstrip().decode('utf-8'))]))


if __name__ == '__main__':
    solve()
# Original solution
from sys import stdin


def b(input_string):
    _s = input_string
    s_length = len(_s)
    s = []
    for i in range(s_length):
        s.append(_s[i])
    #print(_s)
    #print(s)
    count = 0
    flag = True
    while flag and len(s) >= 2:
        flag = False
        for i in range(s_length):
            if i < len(s)-1:
                if s[i] != s[i+1]:
                    s.pop(i)
                    #print(s)
                    s.pop(i)
                    #print(s)
                    count += 2
                    flag = True
                    break
    return count



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


if __name__ == '__main__':
    main()


# Optimized solution
from sys import stdin


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



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


if __name__ == '__main__':
    main()
# Original solution
S = input()
N = len(S)

count = 0
tmp  = 1
dst = S
while True:
    dst1 = dst.replace('01', '')
    dst2 = dst1.replace('10', '')
    if len(dst) - len(dst2) <= 0: break
    count += len(dst) - len(dst2)
    dst = dst2

print(count)

# Optimized solution
S = input()
print((min(S.count('1'), S.count('0')) * 2))
# Original solution
S=input().strip()
N=len(S)
q = [S]
while q:
    s = q.pop()
    p = ''
    v = 0
    for i,c in enumerate(s):
        if (p == '0' and c == '1') or (p == '1' and c == '0'):
            q.append(s[:i-1]+s[i+1:])
            v += 1
        p = c
    if v == 0:
        print((N-len(s)))
        break

# Optimized solution
S=input().strip()
N=len(S)

a=[0 if x == '0' else 1 for x in S]

while True:
    v = 0
    p = -1
    b = []
    for i in a:
        if p >= 0:
            if p == 0 or p == 1:
                if i == 0 or i == 1:
                    if p != i:
                        p = -1
                        v += 1
                        continue
            b.append(p)
        p = i
    if p >= 0:
        b.append(p)
    if v == 0:
        print((N - len(a)))
        break
    a = b
# Original solution
S = input()
S = str(S)

counter = 0


while True:
    killer = 0

    killer += int(S.count('10'))
    S = S.replace('10','')

    killer += int(S.count('01'))
    S = S.replace('01','')

    counter += int(killer)

    if killer == 0:
        break
print(counter * 2)


# Optimized solution
S = 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)
# Original solution
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()


# Optimized solution
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()
# Original solution
S=input()
A=[s for s in S]

while True:
    A_new=[]
    i=0
    while i<len(A):
        if i<len(A)-1:
            if A[i]!=A[i+1]:
                i+=2
            else:
                A_new.append(A[i])
                i+=1
        else:
            A_new.append(A[i])
            i+=1
    if A==A_new:
        break
    else:
        A=A_new[:]
print(len(S)-len(A))

# Optimized solution
S=input()
A=[]
Ans=0
for i in range(len(S)):
    if len(A)>0:
        if A[-1]!=S[i]:
            A.pop()
            Ans+=2
        else:
            A.append(S[i])
    else:
        A.append(S[i])

print(Ans)
# Original solution
#!/usr/bin/env python3
import sys


def solve(S: str):
    n = len(S)
    while True:
        l = len(S)
        for i in range(len(S) - 1):
            if S[i] != S[i + 1]:
                S = S[:i] + S[i + 2:]
                break
        if l == len(S):
            break
    print((n - len(S)))
    return

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

if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
import sys


def solve(S: str):
    n = len(S)
    while True:
        l = len(S)
        i = 0
        while True:
            if i >= len(S) - 1:
                break
            if S[i] != S[i + 1]:
                S = S[:i] + S[i + 2:]
                i = max(i - 1, 0)
            else:
                i += 1
        if l == len(S):
            break
    print((n - len(S)))
    return

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

if __name__ == '__main__':
    main()
# Original solution
import re
  
bit_string = input()

replaced_count = 0
replaced_string = bit_string
while re.search('01|10', replaced_string):
  replaced_string, tmp_count = re.subn('01|10', '', replaced_string)
  replaced_count += tmp_count
print((replaced_count * 2))

# Optimized solution
bit_string = input()
  
count_zero = bit_string.count('0')
count_one  = bit_string.count('1')
print((min(count_zero, count_one) * 2))
# Original solution
#!/usr/bin/env python3
import sys


def solve(S: str):
    nS = len(S)
    pS = ""
    while pS != S:
        pS = S
        S = S.replace("01", "")
        S = S.replace("10", "")
    print((nS - len(S)))


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


if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
import sys


def solve(S: str):
    print((min(S.count("0"), S.count("1")) * 2))


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


if __name__ == '__main__':
    main()
# Original solution
S = input();

cnt = 0;

while True:
	for i in range(len(S)):
		tmp = S.replace('01', '', 1);
		if S != tmp:
			cnt += 2;
			S = tmp;
			break;

		tmp = S.replace('10', '', 1);
		if S != tmp:
			cnt += 2;
			S = tmp;
			break;

	if len(set(S)) <= 1:
		break;

print(cnt);

# Optimized solution
S = input();

S1 = S.count('1');
S0 = S.count('0');

if S1 > S0:
	print(S0 * 2);

else:
	print(S1 * 2);
# Original solution
import sys
import re
s = sys.stdin.read().strip()
n = len(s)

while len(re.findall("10|01", s)) > 0:
    s = re.sub("10|01", "", s)
print((n - len(s)))

# Optimized solution
import sys
s = sys.stdin.read().strip()
n = len(s)
print((2 * min(s.count("0"), s.count("1"))))
# Original solution
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

s, = read_line(str)

s = [int(c) for c in s]

c = 0
while True:
    i = 0
    while i < len(s) - 1:
        if s[i] != s[i + 1]:
            s[i] = s[i + 1] = -1
            i += 2
            c += 2
        i += 1
    s = [c for c in s if c >= 0]
    l = len([c for c in s if c == 0])
    if l == 0 or l == len(s):
        break

print(c)


# Optimized solution
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

s, = read_line(str)

s = [int(c) for c in s]

c = 0

ss = 0

for i in range(0, len(s)):
    if s[i] == 1:
        if ss < 0:
            c += 2
        ss += 1
    else:
        if ss > 0:
            c += 2
        ss -= 1
print(c)
# Original solution
import sys
input = sys.stdin.readline
S=list(input().strip())

flag=True
cnt=0
i=0
f=[]
if len(S) != 1:
    while flag:
        if S[i] != S[i+1]:
            f.append(i)
            f.append(i+1)
            i+=2
        else:
            i+=1
        if i>=len(S)-1:
            cnt+=len(f)
            f.reverse()
            for k in f:
                S.pop(k)
            f=[]
            if '1' not in S or '0' not in S:
                break
            i=0
print(cnt)

# Optimized solution
import sys
input = sys.stdin.readline
S=list(input().strip())
zero=S.count('0')
one=S.count('1')
print((min(zero,one)*2))
# Original solution
def remove01Pair(R):
    for i in range(len(R) - 1):
        #print(i)
        if R[i:i + 2] == '01':
            R = R[:i] + R[i + 2:]
            #print(R)
            return R
    flag[0] = 1
    return R

def remove10Pair(R):
    for i in range(len(R) - 1):
        #print(i)
        if R[i:i + 2] == '10':
            R = R[:i] + R[i + 2:]
            #print(R)
            return R
    flag[0] = 1
    return R

N = input().strip()
#print(N)
length = len(N)
#print(length)
flag = []
flag.append(0)
while flag[0] == 0:
    N = remove01Pair(N)
    #print(N)
    #time.sleep(1)
flag[0] = 0
while flag[0] == 0:
    N = remove10Pair(N)
    #print(N)
    #time.sleep(1)
#print()
#print(len(N))
print((length - len(N)))



# Optimized solution
N = input().strip()
#print(N)
length = len(N)
#print(length)
totalZeros = 0
totalOnes = 0
for i in N:
    if i == '0':
        totalZeros += 1
    else:
        totalOnes += 1
if totalOnes < totalZeros:
    answer = totalOnes * 2
else:
    answer = totalZeros * 2

print(answer)
# Original solution
import sys
input = sys.stdin.readline
import re
def print_ans(S):
    """Test Case
    >>> print_ans("0011")
    4
    >>> print_ans("11011010001011")
    12
    >>> print_ans("0")
    0
    """
    flg = True
    ans = 0
    while flg:
        tmp = re.sub(r"01|10", "", S)
        if len(tmp) == len(S):
            flg = False
            break
        else:
            ans += len(S) - len(tmp)
            S = tmp
    print(ans)
        


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


# Optimized solution
import sys
input = sys.stdin.readline
import re
def print_ans(S):
    """Test Case
    >>> print_ans("0011")
    4
    >>> print_ans("11011010001011")
    12
    >>> print_ans("0")
    0
    """
    flg = True
    ans = 0
    # while flg:
    #     tmp = re.sub(r"01|10", "", S)
    #     if len(tmp) == len(S):
    #         flg = False
    #         break
    #     else:
    #         ans += len(S) - len(tmp)
    #         S = tmp
    # print(ans)
    list_0 = []
    list_1 = []
    for s in S:
        if s =="0":
            list_0.append(s)
        else:
            list_1.append(s)
    print((min(len(list_0), len(list_1)) * 2))
        


if __name__ == '__main__':
    S = input().rstrip()
    print_ans(S)
# Original solution
# -*- coding: utf-8 -*-

S = input().strip()
#-----

cnt=0
while (S.count("01") != 0) or (S.count("10") != 0):
    cnt += S.count("01")
    S = S.replace("01", "")
    
    cnt += S.count("10")
    S = S.replace("10", "")
    
print((cnt*2))


# Optimized solution
# -*- coding: utf-8 -*-

S = input().strip()
#-----

num_red = S.count("0")
num_blue = len(S) - num_red

print(( min(num_red,num_blue) * 2 ))
# Original solution
# -*- coding: utf-8 -*-

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

    sl = list(s[0])
    prev = -1
    n = 0
    while True:
        # print(str(sl))
        if len(sl) < 1:
            break
        kita = False
        for i, c in enumerate(sl):
            if i == 0 and prev != -1:
                break
            if (prev == 0 and c == '1') or (prev == 1 and c == '0'):
                kita = True
                # print("remove", i, prev, c)
                del sl[i]
                del sl[i-1]
                n += 2
                prev = -1
                break
            else:
                kita = True
                prev = int(c)

        if not kita:
            break

    print(n)

main()


# Optimized solution
# -*- coding: utf-8 -*-

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

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

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

        if (prev == 0 and sl[i] == '1') or (prev == 1 and sl[i] == '0'):
            # print(str(sl))
            # print("remove", i, prev, sl[i])
            del sl[i]
            del sl[i-1]
            n += 2
            if i-2 < 0:
                prev = -1
                i = 0
            else:
                prev = int(sl[i-2])
                i = i-1
        else:
            prev = int(sl[i])
            i += 1

    print(n)

main()
# Original solution
import sys

def solve():
    input = sys.stdin.readline
    zero, one = 0, 0
    s = input().strip("\n")
    for i in range(len(s)):
        if s[i] == "0": zero += 1
        else: one += 1
    print((2 * min(zero, one)))

    return 0

if __name__ == "__main__":
    solve()

# Optimized solution
import sys

def solve():
    input = sys.stdin.readline
    S = input().strip("\n")
    zero, one = 0, 0
    for i in range(len(S)):
        if S[i] == "0": zero += 1
        else: one += 1
    print((2 * min(zero, one)))

    return 0

if __name__ == "__main__":
    solve()
# Original solution
S = input().strip()
N = len(S)
k = 0
for i in range(N):
    if S[i]=="0":
        k += 1
m = min(k,N-k)
print((2*m))

# Optimized solution
S = input().strip()
N = len(S)
cnt = 0
for i in range(N):
    if S[i]=="1":
        cnt += 1
print((min(cnt,N-cnt)*2))
# Original solution
S = input().strip()
N = len(S)
cnt = 0
for i in range(N):
    if S[i]=="1":
        cnt += 1
print((min(cnt,N-cnt)*2))

# Optimized solution
S = input().strip()
cnt0 = 0
cnt1 = 0
for i in range(len(S)):
    if S[i]=="0":
        cnt0 += 1
    else:
        cnt1 += 1
print((min(cnt0,cnt1)*2))
# Original solution
import sys
fin = sys.stdin.readline

import copy
ob = list(fin())
for i in range(len(ob)-1):
     if ob[i]=="0" and ob[i+1]=="1":
          ob[i]="1"
          ob[i+1]="0"
n = len(ob)
while True:
     ob_sub = copy.copy(ob)
     j=0
     for i in range(len(ob)-1):
          if ob[i]=="1" and ob[i+1]=="0":
               ob_sub[i],ob_sub[i+1] = "#","#"
               j+=2
     for i in range(j):
          ob_sub.remove("#")
     if ob_sub == ob:
          break
     else:
          ob = ob_sub
          
while True:
     ob_sub = copy.copy(ob)
     j=0
     for i in range(len(ob)-1):
          if ob[i]=="0" and ob[i+1]=="1":
               ob_sub[i],ob_sub[i+1] = "#","#"
               j+=2
     for i in range(j):
          ob_sub.remove("#")
     if ob_sub == ob:
          break
     else:
          ob = ob_sub

print((n-len(ob)))

# Optimized solution
import sys
fin = sys.stdin.readline
ob = list(fin())
print((min(ob.count("0"), ob.count("1"))*2))
# Original solution
s=input().count;print((min(s('0'),s('1'))*2))

# Optimized solution
print((min(list(map(input().count,'01')))*2))
# Original solution
# デバッグ用
GBN_DEBUG = False
GBN_DEBUG = True
def dprn(s, i):
    if GBN_DEBUG: print(", " + s + " = " + str(i), end = "")
def dprns(s):
    if GBN_DEBUG: print(", " + s, end = "")
def dprni(i):
    if GBN_DEBUG: print(i, end=" ")
def endl(): 
    if GBN_DEBUG: print('')
def puts(s): print(s)

#本体ここから

S = input()
#N = int(input())
#S, T = input().split()
#N, M = map(int, input().split())
#W = [input() for _ in range(N)]
#A = A = list(map(int, input().split()))

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


# Optimized solution
# デバッグ用
GBN_DEBUG = False
GBN_DEBUG = True
def dprn(s, i):
    if GBN_DEBUG: print(", " + s + " = " + str(i), end = "")
def dprns(s):
    if GBN_DEBUG: print(", " + s, end = "")
def dprni(i):
    if GBN_DEBUG: print(i, end=" ")
def endl(): 
    if GBN_DEBUG: print('')
def puts(s): print(s)

#本体ここから

S = input()
#N = int(input())
#S, T = input().split()
#N, M = map(int, input().split())
#W = [input() for _ in range(N)]
#A = list(map(int, input().split()))

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

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