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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S=input()
n0,n1=0,0
for s in S:
  if s=='1':
    n1+=1
  elif s=='0':
    n0+=1
print(min(n1,n0))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    S = input()

    ans = 0

    for i in range(10):
        if '0011' in S:
            ans += 4 * S.count('0011')
            S = S.replace('0011', '')
        if '1010' in S:
            ans += 4 * S.count('1010')
            S = S.replace('1010', '')
        if '0101' in S:
            ans += 4 * S.count('0101')
            S = S.replace('0101', '')
        if '1100' in S:
            ans += 4 * S.count('1100')
            S = S.replace('1100', '')
    for i in range(10):
        if '01' in S:
            ans += 2 * S.count('01')
            S = S.replace('01', '')
        if '10' in S:
            ans += 2 * S.count('10')
            S = S.replace('10', '')
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    S = input()

    ans = 0

    if '0011' in S:
        ans += 4 * S.count('0011')
        S = S.replace('0011', '')
    if '1010' in S:
        ans += 4 * S.count('1010')
        S = S.replace('1010', '')
    if '0101' in S:
        ans += 4 * S.count('0101')
        S = S.replace('0101', '')
    if '1100' in S:
        ans += 4 * S.count('1100')
        S = S.replace('1100', '')
    if '01' in S:
        ans += 2 * S.count('01')
        S = S.replace('01', '')
    if '10' in S:
        ans += 2 * S.count('10')
        S = S.replace('10', '')
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
S = str(input())
x = len(S)
if S[0] == '1':
    while '10' in S:
        S = S.replace('10', '')
    S = S.replace('01', '')
else:
    while '01' in S:
        S = S.replace('01', '')
    S = S.replace('10', '')

print(x - len(S))

Submission status: Wrong Answer

Solution code:
S = str(input())
x = len(S)
if S[0] == '1':
    while '10' in S:
        S = S.replace('10', '')
    S = S.replace('01', '')
else:
    while '01' in S:
        S = S.replace('01', '')
S = S.replace('10', '')

print(x - len(S))

Submission status: Wrong Answer

Solution code:
S = str(input())
x = len(S)
while '01' in S:
  S = S.replace('01', '')
S = S.replace('10', '')
  
print (x-len(S))

Submission status: Wrong Answer

Solution code:
S = str(input())

S1 = S.replace('01', '')
S2 = S1.replace('10', '')
S3 = S2.replace('01', '')
print(len(S)-len(S3))

Submission status: Wrong Answer

Solution code:
s = list(input())

ans = 0
flag = 1
while (flag):
    flag = 0
    i = 0
    loop_len = len(s)
    while (i < (loop_len - 1)):
        print(loop_len)
        print(s)
        if (s[i] != s[i + 1]):
            flag = 1
            ans += 2
            del s[i: i + 2]
        loop_len = len(s)
        i += 1

print(ans)

Submission status: Wrong Answer

Solution code:
S = list(input())
N = len(S)
while(1):
    Q = []
    for i in range(len(S)-1):
        if S[i]!=S[i+1]:
            i += 1
        else:
            Q.append(S[i])
    Q.append(S[-1])
    if S == Q:
        break
    S = Q 
    #print(S)
print(N-len(S))

Submission status: Wrong Answer

Solution code:
import math
s = list(input())
s = list(map(int, s))
s_ori = s.copy()
s_len = len(s)

s_new=[]
for k in range(200000):
    if k >=10000:
        print(k)
        break
    count=0
    s_len = len(s)
    if s_len ==1:
        #print('a')
        break
    for i in range(1,s_len):
        if count %2==1:
            count +=1
            if i +1==s_len:
                s_new.append(s[-1])
            continue
        if s[i] is not s[i-1]:
            count +=1
        else:
            s_new.append(s[i-1])
            if i +1==s_len:
                s_new.append(s[-1])
    #print(s_new)
    if s==s_new:
        s = s_new
        break
    s = s_new
    s_new=[]
    
#print(s_ori)    
print(s)
print(math.floor((len(s_ori)-len(s))/2)*2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7


n = ri()
s = collections.Counter(rr())
print(min(s['0'], s['1']) * 2)

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7


n = ri()
s = collections.Counter(rr())
print(min(s['0'], s['1']))

Submission status: Wrong Answer

Solution code:
S = list(input())
S.append("end")
S.append("end")
S.append("end")


i = 1
ans = 0

while S[i] != "end":
    if S[i] != S[i - 1]:
        del(S[i - 1])
        del(S[i - 1])
        i -= 1
        ans += 2
    else:
        i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
S=input()+'9'

tmp=[]
cnt=0
while 2<=len(set(S)):
    # print(S)
    i=0
    while i < len(S)-1:
        if S[i+1]=='9': # 番兵法
            tmp.append(S[i])
            break
        if S[i] == S[i+1]:
            tmp.append(S[i])
            i+=1
        else:
            cnt+=2
            i+=2
            
    S=''.join(tmp)
    tmp=[]
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    S = list(input())
    d_1 = deque(S[1:])
    d_2 = deque(S[0])
    ans = 0
    for i in range(1, len(S)):
        if d_2:
            r = d_1.popleft
            l = d_2.pop()
            if r == l:
                ans += 2
            else:
                d_2.append(l)
                d_2.append(r)
        else:
            d_2.append(d_1.popleft())
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def solve():
  S = input()
  one,zero = 0,0
  for s in S:
    if s=='0':
      zero += 1
    else:
      if zero>0:
        one += 1
  ans = min(one,zero)*2
  return ans
print(solve())

Submission status: Wrong Answer

Solution code:
S = list(input())
p_s = None
ans = 0

for s in S:
    if (s == '1' and p_s == '0') or (s == '0' and p_s == '1'):
        ans += 2
    else:
        p_s = s

print (ans)

Submission status: Wrong Answer

Solution code:
s=list(input())
n=len(s)
a=s.count('1')
b=n-a
print(abs(a-b))

Submission status: Wrong Answer

Solution code:
# abc120_c.py
# https://atcoder.jp/contests/abc120/tasks/abc120_c

# C - Unification /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 300点

# 問題文
# 机の上に N個のキューブが縦に積まれています。長さ N の文字列 Sが与えられます。
# 下から i番目のキューブの色は、S の i文字目が 0 のとき赤色、1 のとき青色です。
# あなたは、赤色のキューブと青色のキューブが隣り合っているような部分を選んで、それら 2個のキューブを取り除く操作を何度でも行えます。
# このとき、取り除いたキューブの上にあったキューブは真下の物体の上に落下します。
# 最大で何個のキューブを取り除けるでしょうか。

# 制約
#     1≤N≤105
#     |S|=N
#     Sの各文字は 0 または 1 である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# S

# 出力
# 最大で何個のキューブを取り除けるかを出力せよ。

# 入力例 1
# 0011

# 出力例 1
# 4

# 以下の順に操作を行うと 4個全てのキューブを取り除けます。

#     下から 2番目のキューブと 3 番目のキューブを取り除きます。その結果、下から 4 番目のキューブが下から 1番目のキューブの上に落下します。
#     下から 1番目のキューブと 2番目のキューブを取り除きます。

# 入力例 2
# 11011010001011

# 出力例 2
# 12

# 入力例 3
# 0

# 出力例 3
# 0


def calculation(lines):
    line = lines[0]
    # N = int(lines[0])
    # A, B, K = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i+1]))

    n0 = 0
    n1 = 1

    for char in line:
        if char == '0':
            n0 += 1
        else:
            n1 += 1

    return [min(n0, n1)*2]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['0011']
        lines_export = [4]
    if pattern == 2:
        lines_input = ['11011010001011']
        lines_export = [12]
    if pattern == 3:
        lines_input = ['0']
        lines_export = [0]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input().strip()
cnt0 = 0
cnt1 = 1
for i in range(len(S)):
    if S[i]=="0":
        cnt0 += 1
    else:
        cnt1 += 1
print(min(cnt0,cnt1)*2)

Submission status: Wrong Answer

Solution code:
S=input()
X=len(S)
A=S
for i in range(10**3+1):
  A=A.replace("10","").replace("01","")
if X==1:
  print(0)
else:
  print(X-len(A))

Submission status: Wrong Answer

Solution code:
S=input()
X=len(S)
A=S.replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","")
B=A.replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","")
C=B.replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","")
D=C.replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","")
E=D.replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","")
F=E.replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","")
if X==1:
  print(0)
else:
  print(X-len(F))