peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
X, N = map(int,input().split())
P = set(map(int,input().split()))
tmp = 101
for i in range(-100,110):
    if i in P:
        continue
    elif tmp > abs(X-i):
        tmp = abs(X-i)
        ans = i
print(ans)
# Judge status: Accepted
def main():
    s = input()
    cnt = 0
    cnt2 = 0
    for i in s:
        if i == "R":
            cnt2 += 1
        else:
            cnt = max(cnt, cnt2)
            cnt2 = 0
    print(max(cnt, cnt2))


main()
# Judge status: Accepted
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

x = ni()
ans_a = 0
ans_b = 0
for a in range(-120, 120):
    for b in range(-120, 120):
        if a**5 - b**5 == x:
            ans_a = a
            ans_b = b

print(ans_a, ans_b)
# Judge status: Accepted
# -*- coding: utf-8 -*-

# 約数を求める時間はない！

N = int(input())

ans = 0
for i in range(1, N + 1):
    n = N // i
    ans += i * (n * (n + 1)) // 2

print(ans)
# Judge status: Wrong Answer
s = input()
count1 = 0
count2 = 0
ans = 0
for i in s:
    if i == ">":
        count1 += 1
        ans += count1
        count2 = 0
    else:
        count2 += 1
        ans += count2
        count1  = 0
print(ans)
# Judge status: Accepted
import sys


INF = 10**60
inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instr = lambda: sys.stdin.readline()
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

k, a, b = inintm()
ans = 0

if a + 2 >= b:
    print(1+k)
else:
    ch = max(0, (k-(a-1))//2)
    print(b + (ch-1)*(b-a) + k-(ch*2+a-1))
# Judge status: Wrong Answer
n = int(input())
for i in range(2**(n-1)):
  s = bin(i)[2:]
  pre = '0'*(n-len(s)) + s
  print(''.join(['a' if t=='0' else 'b' for t in pre]))
# Judge status: Wrong Answer
n = int(input())

if n >= 15:
    800 * n - (200 * n // 15)
else:
    print(800 * n )
# Judge status: Wrong Answer
N = int(input())
P = list(map(int,input().split()))

ans = 0
for i in range(0,N):
  a = True
  for j in range(0,N):
    if P[i] <= P[j]:
      a = True
    else:
      a = False
  if a == True:
    ans += 1

print(ans)
# Judge status: Accepted
n = int(input())
from collections import defaultdict
dic = defaultdict(int)

for i in range(n+1):
    i = str(i)
    dic[(i[0], i[-1])] += 1


ans = 0
for i in range(1,10):
    for j in range(1,10):
        i = str(i)
        j = str(j)
        ans += dic[i,j] * dic[j,i]

print(ans)
# Judge status: Accepted
N = int(input())

print(1 - (N//2)/N)
# Judge status: Accepted
k,x=map(int,input().split())
print("Yes" if 500*k>=x else "No")
# Judge status: Wrong Answer
N,M=map(int,input().split())
if N>1 and M>1:
  print(int((N*(N-1)/2)+(M*(M-1)/2)))
elif N<=1:
    if M<=1:
      print(0)
    print(int(M*(M-1)/2))
else:
  print(int(N*(N-1)/2))
# Judge status: Accepted
import collections

n = int(input())
s = str(input())
ans = 1

s_l = [s.count('R'), s.count('G'), s.count('B')]
for k in s_l:
    ans *= k


cnt = 0
for i in range(1, n-1):
    for j in range(1, min(i, n - i - 1) + 1):
        if s[i] != s[i - j] and s[i] != s[i + j] and s[i - j] != s[i + j]:
            cnt += 1

print(ans - cnt)
# Judge status: Accepted
N = input()
keta = len(N)
keta_sum = sum(list(map(int, list(N))))

ans = max(int(N[0]) - 1 + 9 * (keta - 1), keta_sum)
print(ans)
# Judge status: Accepted
a, b = [int(i) for i in input().split()]

if a <= 8 and b <= 8:
  print("Yay!")
else:
  print(":(")
# Judge status: Accepted
import math
a=int(input())
ans=a
ct=0
while ct<=(math.sqrt(a)-1):
    ct+=1
    if a%ct==0:
        if ans>=((a/ct)+ct):
            ans=((a/ct)+ct)
if a==ans:
    ans+=1
if a==4:
    ans=4
print(int(ans-2))
# Judge status: Accepted
A,B,C,D = map(int, input().split())
while True:
    C -= B
    if C <= 0:
        print('Yes')
        break
    A -= D
    if A <= 0:
        print('No')
        break
# Judge status: Wrong Answer
n = int(input())
list_A = list(map(int, input().split()))
list_N = [0]*n

for i in range(n, 0, -1):
    k, cnt = 0, 0
    while True:
        if k+i >= n:
            break
        if list_N[k+i-1] == 1:
            cnt += 1
        k += i
    list_N[i-1] = (list_A[i-1]+cnt) % 2

ans = []
for i in range(n):
    if list_N[i] == 1:
        ans.append(i+1)
print(len(ans))
print(*ans)
# Judge status: Accepted
s = list(input())
l = len(s)
s.append("?")
ans = 0
w = "!"
x = 0
for i in range(l):
    if x == 1:
        x = 0
    elif s[i] == w:
        ans += 1
        x = 1
        w = s[i] + s[i + 1]
        if i == l - 1:
            ans -= 1
    else:
        ans += 1
        w = s[i]
print(ans)
# Judge status: Accepted
N=int(input())
Atamasiri = [[0 for i in range(10)] for j in range(10)]#Atamasiri[atama][siri]
cursaijou = 1
for n in range(1,N+1):
    if n>=cursaijou*10:
        cursaijou *= 10
    atama = n//cursaijou
    siri = n%10
    Atamasiri[atama][siri] += 1
ans = 0
for head in range(10):
    for ketsu in range(10):
        ans += Atamasiri[head][ketsu]*Atamasiri[ketsu][head]
print(ans)
# Judge status: Accepted
def calc(n, k):
    if n == 0:
        return 0
    if n > k:
        a = n%k
        return min(abs(a-k), a)
    # kのほうがnより大きいとき
    if n*2 < k:
        return n
    else:
        # k = k%n+n+n
        return min(abs(n-k), k-abs(n-k))

n, k = (int(each) for each in input().split())
print(calc(n, k))
# Judge status: Wrong Answer
print('0' if input()=='1' else '0')
# Judge status: Wrong Answer

a,b,c = map(int,input().split())

if a+b <= c:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = input()

sum_val = 0
for i in range(len(n)):
    sum_val += int(n[i])

if sum_val % 9 == 0:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n=int(input())
l=[]
for _ in range(n):
  l.append(list(map(int, input().split())))
#print(l)
import itertools
d=len(list(itertools.permutations(l)))/2
cnt=0
fin=[]
for v in itertools.permutations(l):
  if cnt==d:
    break
  else:
    cnt+=1
    chk=[]
    for z in range(len(v)-1):
      chk.append(((v[z][0]-v[z+1][0])**2+(v[z][1]-v[z+1][1])**2)**0.5)
    fin.append(sum(chk))
print(sum(fin)/len(fin))
# Judge status: Accepted
N=input()
A=int(N[0])
E=7-A
for i in range(8):
 F=["-","-","-"]
 B=int(N[1])
 C=int(N[2])
 D=int(N[3])
 for j in range(3):
  if ((i >> j) & 1):
   F[j]="+"
 if F[0]=="-":
  B*=-1
 if F[1]=="-":
  C*=-1
 if F[2]=="-":
  D*=-1
 if B+C+D==E:
  print(str(A)+str(F[0])+str(abs(B))+str(F[1])+str(abs(C))+str(F[2])+str(abs(D))+"=7")
  break
# Judge status: Wrong Answer
def main():
    n = int(input())
    a_lst = list(map(int, input().split()))
    average = sum(a_lst) // n
    if sum(a_lst) % n != 0:
        average += 1

    minimum = 0
    for i in range(n):
        a = a_lst[i]
        minimum += (a - average) ** 2
    print(minimum)


if __name__ == '__main__':
    main()
# Judge status: Accepted
def main():
  from itertools import groupby
  s, n = list(input()), int(input())
  f = False
  for k,v in groupby(s):
    if f:
      print(k)
      break
    if k == '1' and len(list(v)) >= n:
      print(1)
      break
    elif k != '1':
      print(k)
      break
    else:
      f = True

if __name__ == '__main__':
  main()
# Judge status: Accepted
import sys
input = sys.stdin.readline

N = int(input())
data = dict()
for _ in range(N):
    s = input()[:-1]
    if s in data:
        data[s] += 1
    else:
        data.setdefault(s, 1)

ans = sorted(data.items(), key=lambda x:x[1], reverse=True)
M = ans[0][1]
A = []
for item, i in ans:
    if M == i:
        A.append(item)
    else:
        break
A.sort()
for item in A:
    print(item)
# Judge status: Accepted
S = input()
N = len(S)
a,b = 0,0
l = [0]

for i in range(N):
  if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T':
    a += 1
    b = 1
  else:
    if b:
      l.append(a)
      b = 0
      a = 0
else:
  if a:
    l.append(a)
  print(max(l))
# Judge status: Accepted
#!/usr/bin/env python
# coding: utf-8

# In[12]:


N,K = map(int, input().split())
A = list(map(int, input().split()))


# In[14]:


ans = (N-1)//(K-1) + min(1, (N-1)%(K-1))
print(ans)


# In[ ]:
# Judge status: Accepted
N = int(input())

ans = 0

for i in range(N):
    s = i+1
    if s % 3 != 0 and s % 5 != 0:
        ans += s
        # print(s)
        
print(ans)
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

n = sum(b) - sum(a)
c = 0
for i in range(N):
    if a[i] > b[i]:
        c += a[i] - b[i]
    elif a[i] < b[i]:
        c += (b[i] - a[i] + 2 - 1) // 2
print('Yes' if c <= n else 'No')
# Judge status: Accepted
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
# map(int, input().split())
# int(input())
# input().split()
# mojiretu = ','.join(str_list)
# sorted(input())

s = sorted(input())
if s[0] == s[1] and s[1] != s[2] and s[2] == s[3]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
t=sum(l)
y=0
x=[0]*(10**5+1)
for i in range(n):
    x[l[i]-1]+=1
r=int(input())
for i in range(r):
    a,b=map(int,input().split())
    if(x[a-1]>0):
       x[b-1]+=x[a-1]
       print(t+b*x[a-1]-a*x[a-1])
       t=t+b*x[a-1]-a*x[a-1]
       x[a-1]=0
    else:
        print(t)
# Judge status: Wrong Answer
n = int(input())
ans = list(input())
count = 0
a = set()
for i in range(n):
    if ans[i] == 'I':
        count += 1
        a.add(count)
    elif ans[i] == 'D':
        count -= 1
        a.add(count)

print(max(a))
# Judge status: Wrong Answer
N = input()
N = [int(s) for s in N]
input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]

count = 0
for x in range(N[0]):
    # print(x)
    flag = 1
    for i in range(x+1):
        # print(i)
        if Line[x] > Line[i]:
            # print(Line[x],Line[i])
            flag = 0
    # print("ss")
    if flag == 1 :
        count += 1

print(count)
# Judge status: Wrong Answer
l,r,d=map(int,input().split())

a=l-1//d
b=r//d

print(b-a)
# Judge status: Wrong Answer
n=int(input())
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
z=[]
while n>0:
  r=n%26
  n=n//26
  z.append(r)
s=''
for x in z:
  let=l[x-1]
  s=let+s
print(s)
# Judge status: Accepted
from collections import Counter
N = int(input())
C = Counter()
for i in range(N):
    si = input()
    C[si] += 1
for s in ['AC', 'WA', 'TLE', 'RE']:
    print(s, 'x', C[s])
# Judge status: Accepted
#c
import itertools
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
num=[i for i in range(1,n+1)]
i=0
a=0
b=0
for x in itertools.permutations(num,n):
    i+=1
    
    if x==p:
        a=i
    if x==q:
        b=i
ans=abs(a-b)
print(ans)
# Judge status: Accepted
a, b = input().split()
print(int(a) * round(float(b) * 100) // 100)
# Judge status: Accepted
K,X = map(int, input().split())
max = X + K 
min = X - K + 1
for i in range(min,max):
    print(i,end=" ")
# Judge status: Wrong Answer
N = int(input())
A = int(input())

a = 0
for i in range(20):
  if N > 500*(i+1):
    a = a + 500
  else:
    continue
    
b = N - a

if b < A:
  print("Yes")
else:
  print("No")
print(b)
# Judge status: Wrong Answer
s=input()
ans = 653
for i in range(len(s)-2):
    x = abs(753 - int(s[i:i+3]))
    print(x)
# Judge status: Wrong Answer
N = int(input())
v = sorted(list(map(int,input().split())))
ans = v[0]
print(v)
for i in range(1,N):
    ans = (ans + v[i])/2
print(ans)
# Judge status: Wrong Answer
import math

n = int(input())

d = {}
for i in range(n):
    s = "".join(sorted(input()))
    if s in d:
        d[s] += 1
    else:
        d[s] = 0

_ans = 0
for k, v in d.items():
    if v == 0:
        continue
    elif v == 1:
        _ans += 1
    else:
        _ans += v + 1

print(_ans)
# Judge status: Wrong Answer
a,b = map(int,input().split())
x = a*b
if x>0:
    print("Positive")
elif x<0:
    print("Negative")
elif x==0:
    print("Zero")
# Judge status: Wrong Answer
n, x = map(int, input().split())
l = [int(i) for i in input().split()]
d = 0
count = 0
for li in l:
    if d <= x:
        count += 1
    d += li
print(count)
# Judge status: Accepted
from collections import Counter

n = int(input())
a = list(map(int, input().split()))

acnt = Counter(a)
num = [0,0]
for i in acnt:
    if acnt[i] >= 4:
        num.append(i)
    if acnt[i] >= 2:
        num.append(i)
num.sort()
print(num[-1] * num[-2])
# Judge status: Accepted
a, b, x = map(int, input().split())
if a > x:
    print('NO')
elif a + b < x:
    print('NO')
else:
    print('YES')
# Judge status: Wrong Answer
d,n=map(int,input().split());print(((n==100)*(d<2)+n)*100**d)
# Judge status: Accepted
H,W=map(int,input().split())
if H==1 or W==1:
    print(1)
else:
    print(int((H*W)//2+(H*W)%2))
# Judge status: Accepted
from collections import deque
import bisect
N=int(input())
L=deque()
for i in range(N):
  s=int(input())
  if i==0:
    L.append(s)
  else:
    if s<=L[0]:
      L.appendleft(s)
    else:
      L[bisect.bisect(L,s-1)-1]=s
print(len(L))
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
l=[]
l.append(a)
l.append(b)
l.append(c)
l.sort()
ans=0
while max(l[0],l[1])<l[2]:
    l[0]+=1
    l[1]+=1
    ans+=1
if (l[2]-l[0])%2==0:
    ans+=(l[2]-l[0])//2
    print(ans)
else:
    print(ans+2)
# Judge status: Accepted
def main():
  s = input()
  t = input()
  t = t[0:len(t)-1]
#  print(s,t)
  ans = 'Yes' if s == t else 'No'
  print(ans)
  
if __name__ == '__main__':
  main()
# Judge status: Accepted
import itertools


n = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
X = list(range(1, n+1))

pattern = list(itertools.permutations(X))
pattern.sort()

a = pattern.index(P)
b = pattern.index(Q)

print(abs(a-b))
# Judge status: Accepted
def resolve():
    A, B, C = map(int, input().split())
    print("Yes" if min(A, B) <= C <= max(A, B) else "No")
resolve()
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
def solve():
    N = int(input())
    z = sorted(sum(map(int,input().split())) for _ in range(N))
    return str(z[-1]-z[0])

if __name__ == '__main__':
    print(solve())
# Judge status: Accepted
S=input()
if S=="BBB" or S=="AAA":
  print("No")
else:
  print('Yes')
# Judge status: Wrong Answer
a,b,c,d=map(int,input().split())
x=(b-a+1)//c
y=(b-a+1)//d
z=(b-a+1)//(c+d)
print(b-a-1-x-y+z)
# Judge status: Accepted
a, b, c = map(int, input().split())

ans = 'YES' if b - a == c - b else 'NO'
print(ans)
# Judge status: Accepted
n=int(input())
s=input()
l=0
r=0
for i in range(n):
  if r==0 and s[i]==')':
    l+=1
  elif s[i]=='(':
    r+=1
  elif r>0 and s[i]==')':
    r-=1
print('('*l+s+')'*r)
# Judge status: Accepted
MOD = 10**9 + 7
N, K = map(int, input().split())

ans = 0
for k in range(K, N+2):
    ans += N*k - (k*(k-1)) + 1
print(ans % MOD)
# Judge status: Accepted
import collections
k = int(input())
queue = collections.deque(range(1, 10))
for i in range(k - 1):
    x = queue.popleft()
    xmod = x % 10
    if xmod != 0:
        queue.append(10 * x + xmod - 1)
    queue.append(10 * x + xmod)
    if xmod != 9:
        queue.append(10 * x + xmod + 1)
print(queue.popleft())
# Judge status: Wrong Answer
a,b = map(float,input().split())

max8 = (a+1) * (1/0.08)
min8 = a * (1/0.08)
max10 = (b+1) * (1/0.1)
min10 = b * (1/0.1)
hachi = [int(min8),int(min8)+1]
jyuu = [i for i in range(int(min10),int(max10))]
if a > b:
    print('-1')
else:
    if hachi[0] in jyuu:
        print(hachi[0])
    elif hachi[1] in jyuu:
        print(hachi[1])
    else:
        print('-1')
# Judge status: Accepted
N, K = map(int, input().split())
S = input()

t = S[0]
c = 0
for i in range(N):
    if S[i] != t:
        c += 1
        t = S[i]

if c <= 2 * K:
    print(N - 1)
else:
    a = c - 2 * K
    print(N - a - 1)
# Judge status: Accepted
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cb=[]
for i in range(m):
    b, c = map(int, input().split())
    cb.append([c,b])
cb.sort(reverse=True)
k=0
for i in range(m):
    j=0
    while j<cb[i][1] and k+j<n and a[k+j]<cb[i][0]:
        a[k+j] = cb[i][0]
        j+=1
    k+=j
    if k==n:
        break
print(sum(a))
# Judge status: Wrong Answer
s = input()
t = input()
if s == t[::-1]:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
W,H,X,Y=map(int,input().split())

ans2=0
if ((W%2==0)*W//2==X)*(X>0) and ((H%2==0)*H//2==Y)*(Y>0):
    ans2=1

ans1=max(min(X*H,(W-X)*H),min(W*Y,W*(H-Y)))

print(ans1,ans2)
# Judge status: Accepted
def resolve():
    import sys
    input = sys.stdin.readline
    
    H, A = map(int, input().split())

    d = H // A
    r = H % A

    if r != 0:
        print(d + 1)
    else:
        print(d)


if __name__ == "__main__":
    resolve()
# Judge status: Accepted
a,*_,e,k=map(int,open(0))
print('Y:a(y !'[e-a>k::2])
# Judge status: Accepted
a, b, c = map(int, input().split())

if 4*a*b < (c-a-b)**2 and c-a-b>0:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N = int(input())
x_list = sorted(list(map(int, input().split())))

count = 0
for i in range(N):
  for j in range(i+1, N):
    if x_list[i]%x_list[j] == 0:
      break
    if j == N-1:
      count += 1
print(count)
# Judge status: Wrong Answer
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=0
cnt=0
for i in range(n):
  cnt+=1
  if x<d:
    break
  d+=l[i]
print(cnt)
# Judge status: Accepted
yyyy, mm, dd = [int(_) for _ in input().split('/')]
print('Heisei' if mm <= 4 else 'TBD')
# Judge status: Accepted
n = int(input())
line = list(map(int, input().split()))
line.sort()
print(line[n//2] - line[n//2 - 1])
# Judge status: Accepted
n = int (input())

xy = []

def dist(a, b):
    return abs(a[0]-b[0]) + abs(a[1]-b[1])
    
for i in range(n):
    x, y = map(int,input().split())
    xy.append([x+y, x-y])

xy.sort(key = lambda x: x[0])

min_z = xy[0][0]
max_z = xy[-1][0]

xy.sort(key = lambda x: x[1])

min_w = xy[0][1]
max_w = xy[-1][1]

print(max(abs(min_z - max_z), abs(min_w - max_w)))
# Judge status: Accepted
N = int(input())
S = []
for i in range(N):
    S.append(input())
S.sort()
S.append("A")
B = []
M = 1
T = 1
for i in range(N):
    if S[i] == S[i+1]:
        T += 1
    elif T < M:
        T = 1
    elif T == M:
        T = 1
        B.append(S[i])
    else:
        M = T
        T = 1
        B = [S[i]]

for i in range(len(B)):
    print(B[i])
# Judge status: Wrong Answer
n = int(input())
num = 10**9 + 7
print((10**n)%num - (9**n)*2%num + (8**n)%num)
# Judge status: Accepted
def main():
    n = int(input())
    a = list(map(int, input().split()))
    color = [False] * 8
    sub_color = 0
    for score in a:
        for i in range(8):
            if i*400 <= score <= 399+(i*400):
                color[i] = True
        if score >= 3200:
            sub_color += 1
    cnt = len([x for x in color if x])
    if cnt == 0:
        print(1, sub_color, sep=" ")
    else:
        print(cnt, cnt+sub_color, sep=" ")

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
a = []
for i in range(3):
    a.append(list(map(int, input().split())))

n = int(input())
for j in range(n):
    b = int(input())
    for j in a:
        if b in j:
            a[a.index(j)][j.index(b)] = 0

ans = 0
for i in range(3):
    if a[0][i] == a[1][i] == a[2][i] == 0:
        ans = 1
if [0, 0, 0] in a:
    ans = 1
if a[0][0] == a[1][1] == a[2][2] == 0:
    ans = 1

if ans == 1:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import itertools

N, M, Q = map(int, input().split())
ABCD = [list(map(int, input().split())) for _ in range(Q)]
#print(ABCD)
ALIST = list(itertools.combinations([i for i in range(1, M+1)], N))

maxtokuten = 0
for A in ALIST:
    tokuten = 0
    for a, b, c, d in ABCD:
        if A[b-1] - A[a-1] == c:
            tokuten += d
        else:
            continue
#    print(tokuten, A)
    maxtokuten = max(maxtokuten, tokuten)

print(maxtokuten)
# Judge status: Accepted
t = input()

t = t.replace("?","D")

print(t)
# Judge status: Wrong Answer
s=input()
t=s[::2]
u=s[1::2]
a=t.count("0")
b=u.count("0")
if a>=b:
  print(len(t)-a+b)
else:
  print(len(u)-b+a)
# Judge status: Accepted
K,N=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
dist=[A[0]+K-A[-1]]+[A[i]-A[i-1] for i in range(1,N)]
print(K-max(dist))
# Judge status: Accepted
def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    m = b % a
    while m:
        a, b = m, a
        m = b % a
    return a


k = int(input())
ans = 0

for a in range(1, k+1):
    for b in range(1, k+1):
        ab = gcd(a, b)
        for c in range(1, k+1):
            ans += gcd(ab, c)
print(ans)
# Judge status: Wrong Answer
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
min_price = max(a)+max(b)

for i in range(M):
    x,y,c = map(int,input().split())
    min_price = min(min_price,a[x-1]+b[y-1]-c)
print(min_price)
# Judge status: Accepted
L = int(input())
x = L/3
print(x**3)
# Judge status: Accepted
n=[int(i) for i in input().split()]
m=[int(j) for j in input().split()]
a=sum(m)*1/(4*n[1])
l=[]
for k in m:
    if k>=a:
        l.append(k)

if len(l)>=n[1]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n, m = map(int, input().split())
ar = [0] * n
for i in range(m):
  a, b = map(int, input().split())
  ar[a-1] += 1
  ar[b-1] += 1
for i in range(n):
  print(ar[i])
# Judge status: Accepted
N,M = map(int,input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
for dx in range(N-M+1):
    for dy in range(N-M+1):
        flg = True
        for i in range(M):
          if A[i+dx][dy:dy+M] != B[i]:
            flg = False
            break
        if flg:
          print("Yes")
          exit()
print("No")
# Judge status: Wrong Answer
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,x=MI()
    aa=LI()
    ans=0
    for i in range(n-1):
        cur=max(aa[i]+aa[i+1]-x,0)
        ans+=cur
        aa[i+1]-=cur
    print(ans)

main()
# Judge status: Wrong Answer
N,K=map(int,input().split())
N = N+1
a = N - K
ans = 0

MM = 10**9 +7

for i in range(K,K+a):
  start = int( ( (i)*(i-1)/2 ) % MM )
  fin = int( ( (N+(N-1)-i)*(i)/2+1 ) % MM )
  ans = int( ( ans + (fin - start) ) % MM )
  print(fin,start)
if N == K:
  ans = ans + 1
print(ans)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-


#----------
W,H,N = list(map(int, input().rstrip().split()))
x_y_a = [list(map(int, input().rstrip().split())) for _ in range(N)]
#----------
x_max,y_max = W,H
x_min,y_min = 0,0

for x,y,a in x_y_a:
    if a == 1:
        x_min = x
    elif a == 2:
        x_max = x
    elif a == 3:
        y_min = y
    elif a == 4:
        y_max = y
    
area = (x_max - x_min) * (y_max - y_min)
if area < 0:
    area = 0

print(area)
# Judge status: Wrong Answer
n = int(input())
a = map(int,input().split())
flag = True
for i in a:
  if i % 2 == 0 and (i % 3 != 0 or 1 % 5 != 0):
    flag = False
print("APPROVED" if flag else "DENIED")
# Judge status: Accepted
n,m,x=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]

ans=10**9
for i in range(2**n):
  t_ans=0
  us=[0 for j in range(m)]
  for k in range(n):
    if (i>>k)&1:
      book=l[k]
      t_ans+=book[0]
      for p in range(m):
        us[p]+=book[p+1]

  if all([q>=x for q in us]):
    ans=min(ans,t_ans)

print(ans if ans!=10**9 else -1)
# Judge status: Accepted
s = input()
ans = 1
prev = s[0]
now = ""

for i in range(1,len(s)):
  now += s[i]
  if now != prev:
    ans += 1
    prev = now
    now = ""

print(ans)