peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N = int(input())
h = list(map(int, input().split()))
ans = [0] * N
ans[0] = 0
ans[1] = abs(h[0]-h[1])
for i in range(2, N):
    ans[i] = min(ans[i-1]+abs(h[i-1]-h[i]), ans[i-2]+abs(h[i-2]-h[i]))
print(ans[-1])
# Judge status: Accepted
a,b,c = map(int,input().split())
if any([i%2 == 0 for i in (a,b,c)]):
    print(0)
else:
    print(min(b*c,c*a,a*b))
# Judge status: Wrong Answer
#B - Tax Rate 
import math
N = int(input())

result = ':('
for i in range(N):
    if math.floor(i * 1.08) == N:#小数点以下切り捨て
        result = i
print(result)
# Judge status: Accepted
X,Y = map(int,input().split())
a = 1
x = X
mul = min(max(X,2),2)
cnt = 1
for i in range(10000):
  x *= mul
  if x>Y:
    cnt+=i
    break
print(cnt)
# Judge status: Accepted
a, b = map(int, input().split())
if a > 9 or b > 9:
  print(-1)
else:
  print(a*b)
# Judge status: Accepted
n,m = map(int, input().split())
a = [str(input()) for i in range(n)]
b = [str(input()) for i in range(m)]
for i in range(0,n-m+1):
    for j in range(0,n-m+1):
        ans = 1
        for k in range(0,m):
            for l in range(0,m):
                if a[i+k][j+l] != b[k][l]:
                    ans = 0
                    break
        if ans == 1:
            print('Yes')
            exit()
print('No')
# Judge status: Accepted
n, p = map(int, input().split())
even_count = sum(a % 2 == 0 for a in map(int, input().split()))
odd_count = n - even_count
if odd_count == 0:
  print(0 if p == 1 else 2 ** even_count)
else:
  print((2 ** even_count) * (2 ** (odd_count - 1)))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

cnt = 1
inc = False
dec = False
p = A.pop(0)

for Ai in A:
    if (not inc) and (not dec):
        if Ai < p:
            dec = True
        elif Ai > p:
            inc = True
    elif inc:
        if Ai < p:
            cnt += 1
            inc = False
    elif dec:
        if Ai > p:
            cnt += 1
            dec = False
    p = Ai
    
print(cnt)
# Judge status: Accepted
s = input()[::-1]

dataset = [0]*2019
dataset[0] = 1

n = 0
d = 1

for i in s:
    n += int(i) * d
    a = n % 2019
    dataset[a] += 1
    d *= 10
    d %= 2019

count = 0
for i in dataset:
    count += i * (i-1) // 2

print(count)
# Judge status: Wrong Answer
a=int(input())
b,d,e=[],[],[]
for i in range(a):
    b.append(str(input()))
c=int(input())
up,down=0,0
for j in range(c):
    d.append(str(input()))
for k in set(b):
    up+=b.count(k)
    down+=d.count(k)
    e.append(up-down)
    up,down=0,0
print(max(e))
# Judge status: Accepted
from collections import defaultdict
N = int(input())
A = input().split()
dic = defaultdict(int)
for a in A:
    dic[int(a)] += 1
ans = 0
for i, v in dic.items():
    if i < v:
        ans += v - i
    elif i > v:
        ans += v
print(ans)
# Judge status: Accepted
N = int(input())
H = list(map(int,input().split()))
D = 0

for n in range(N):
  if D>H[n]:
    print("No")
    exit()
  elif D<=H[n]-1:
    H[n]-=1
    D=H[n]

print("Yes")
# Judge status: Wrong Answer
N = int(input())
S =list(input())
ans = N
W = 0
E = S.count('E')

for i in S:
    ans = min(ans, W+E)
    if i == 'W':
        W +=1
    else:
        E -= 1
print(ans)
# Judge status: Accepted
print('win' if sum(map(int,input().split())) <= 21 else 'bust')
# Judge status: Accepted
import sys
import copy
import math
import itertools
import numpy as np
l = [int(c) for c in input().split()]
N = l[0]
M = l[1]
KA = [list(map(int,input().split())) for c in range(N)]

F = [0]*M

for i in range(N):
    for j in range(1,KA[i][0]+1):
        F[KA[i][j]-1]+=1
print(F.count(N))
# Judge status: Accepted
N, K = map(int, input().split())
sunuke = [0] * N
for i in range(K):
    d = int(input())
    A = list(map(int, (input().split())))
    for j in range(d):
        sunuke[A[j]-1] = 1
ans = N - sum(sunuke)
print(ans)
# Judge status: Wrong Answer
x = int(input())

#2回で3~11を作れる
count = 0
if x == 7:
  count=2
  x = 0

count += (x//11)*2
x = x%11
if x==0:
  count += 0
elif x>6:
  count+=2
elif x<6:
  count += 1


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

K = int(input())

X = int(input())

Y = int(input())

if N <= K:
  print(X*N)
else:
  print(X*K + Y*(N-K))
# Judge status: Wrong Answer
k=int(input())
l=list(range(1, k+1))
import itertools
import math
from functools import reduce
def gcd(*numbers):
  return reduce(math.gcd, numbers)
ans=0
for v in itertools.combinations_with_replacement(l, 3):
  ans+=gcd(*v)
print(ans)
# Judge status: Wrong Answer
a = int(input())
s = input()
if a>3219:
    print(s)
else:
    print("red")
# Judge status: Accepted
N = input()
A = list(map(int, input().split()))

num = round(sum(A) / len(A))
cost = [(a - num)**2 for a in A]

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

ans = 1
MOD = 10**9 + 7

for i in range(1, N+1):
    ans *= i
    ans %= MOD

print(ans)
# Judge status: Wrong Answer
n = int(input())
p = list(map(int,input().split()))
c = 0
for i in range(1,n+1):
  if p != i:
    c += 1
if c == 2 or c == 0:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
a, b, c, x, y = (int(each) for each in input().split())

cost = [x*a + y*b]
for i in range(max(x, y)*2+1):
    numofabpizza = i*2
    numofapizza = max(0, (x-numofabpizza))
    numofbpizza = max(0, (y-numofabpizza))
    # print(numofapizza, numofbpizza, numofabpizza)
    cost.append(numofapizza*a + numofbpizza*b + (2*numofabpizza)*c)
# print(cost)
print(min(cost))
# Judge status: Accepted
n, x, y = list(map(int, input().split()))

dist = [0 for _ in range(n - 1)]

for i in range(n):
    for j in range(i + 1, n):
        k = min(j - i,
                abs(x - 1 - i) + 1 + abs(y - 1 - j))
        dist[k - 1] += 1

for k in range(1, n):
    print(dist[k - 1])
# Judge status: Accepted

A, B, C, K = map(int, input().split())
r = K % 2
if r == 0:
    ans = A - B
else:
    ans = B - A

if abs(ans) > 10**18:
    print('Unfair')
else:
    print(ans)
# Judge status: Wrong Answer
# coding: utf-8
# Your code here!
n,m=map(int,input().split())
a=list(map(int,input().split()))
if len(a)==0:
  print(n)
else:
  a.sort()
  if n not in a:
    print(n)
  else:
    cnt=0
    for i in range(101):
      if i in a:
        continue
      elif abs(cnt-n)>abs(i-n):
        cnt=i
    print(cnt)
# Judge status: Accepted
n,k = map(int, input().split())

lis = sorted(list(map(int, input().split())))

ans = []
for i in range(n-k+1):
    a = lis[i]
    b = lis[i+k-1]
    ans.append(min(abs(a)+abs(b-a),abs(b)+abs(a-b)))

print(min(ans))
# Judge status: Wrong Answer
x,y= map(int,input().split())

for i in range(1,101):
    if x - i == 0:
        break
    else:
        for j in range(1,x - i + 1):
            if 2 * i + 4 * j == y:
                print("Yes")
                exit()
print("No")
# Judge status: Wrong Answer
a = list(map(int,input().split()))
a.sort()
b = a[2] - a[1]
c = a[2] - a[0]
ans = 0

ans += b

if (c-b) % 2 == 0:
    ans += (c-b)//2
elif (c-b) % 2 == 0:
    ans += (c-b)//2 + 2

print(ans)
# Judge status: Accepted
N = int(input())
a = list(map(int,input().split()))

num = [0]*(10**5+1)
for i in a:
    if i-1 >= 0:
        num[i-1] += 1
    num[i] += 1
    if i+1 <= N:
        num[i+1] += 1

print(max(num))
# Judge status: Accepted
from collections import Counter

n = int(input())
al = list(map(int, input().split()))
c = Counter(al)

ans = 0
for k, v in c.items():
    if k == v:
        continue
    elif k > v:
        ans += v
    else:
        ans += v-k

print(ans)
# Judge status: Accepted
n = int( input() )
s = list( map( int, input().split() ))

total = sum( s )

minimum = total
part1 = total
for i in range( len( s ) ):
  part1 = part1 - s[ i ]
  minimum = min( minimum, abs( total - 2 * part1 ))
  if total - 2 * part1 >= 0:
    break
    
print( minimum )
# Judge status: Accepted
d, n = map(int, input().split())

if(d == 0):
    print(n if n < 100 else n+1)
else:
    print(100**d * n if n < 100 else 100**d * (n+1))
# Judge status: Wrong Answer
from itertools import groupby
inputs = open(0).readlines()

n = int(inputs[0])
*D, = map(int, inputs[1].split())
D.sort()
mod = 998244353

keys, nodes = [], [] 
for k, g in groupby(D):
    keys.append(k)
    nodes.append(len(list(g)))

if nodes[0] != 1 or any(i != k for i, k in enumerate(keys)):
    print(0)
else:
    patterns = [1]
    for n0, n1 in zip(nodes, nodes[1:]):
        patterns.append(patterns[-1] * pow(n0, n1, mod) % mod)
    print(patterns[-1])
# Judge status: Wrong Answer
N = int(input())
xs = []
ys = []
for _ in range(N):
    x,y = map(int,input().split())
    xs.append(x)
    ys.append(y)
fxys = []
for i in range(N):
    x = xs[i]
    y = ys[i]
    fxys.append((x-y, x+y))
m = 0
for d in [0, 1]:
    mx = 0
    mi = float("inf")
    for i in range(N):
        mx = max(fxys[i][d], mx)
    for i in range(N):
        mi = min(fxys[i][d], mi)
    m = max(mx-mi, m)
print(m)
# Judge status: Accepted
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
B = np.array(list(map(int, input().split())))
C = np.array(list(map(int, input().split())))

A.sort()
B.sort()
C.sort()

cnt_A = np.searchsorted(A,B)
cnt_C = N - np.searchsorted(C,B,side='right')
ans = (cnt_A*cnt_C).sum()

print(ans)
# Judge status: Accepted
import itertools
S=input()
N=len(S)+1
ans=0
KEY=[]
gr=itertools.groupby(list(S))
i=0
for key,group in gr:
  n=len(list(group))
  ans+=n*(n+1)//2
  KEY+=[n]
  if key==">" and i!=0:
    ans-=min(KEY[i-1],KEY[i])
  i+=1
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
a = [i-1 for i in map(int, input().split())]

left, right = 0, 10**9
while left < right:
    middle = (left+right)//2
    if middle==0:
        left=1
        break
    count = 0
    for i in a:
        count += i//middle
    
    if count <= k:
        right = middle
    else:
        left = middle + 1

print(left)
# Judge status: Accepted
x,a,b = map(int, input().split())

if b <=a :
    print("delicious")
elif b - a <= x:
    print("safe")

else:
    print("dangerous")
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7

c = [n]*61
for i in range(n):
    b = str(bin(a[i]))[2:]
    b = b[::-1]
    for j, x in enumerate(b):
        if x == "1":
            c[j] -= 1

ans = 0
for i in range(60):
    ans += c[i]*(n-c[i])*pow(2,i,mod)
    ans %= mod
print(ans)
# Judge status: Accepted
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
d = list(map(int, input().split()))
M = 998244353
from collections import Counter
c = Counter(d)
if d[0]!=0 or c[0]>=2:
    ans = 0
else:
    m = max(c.keys())
    ans = 1
    for i in range(1,m+1):
        if i not in c:
            ans = 0
            break
        ans *= pow(c[i-1], c[i], M)
        ans %= M
print(ans%M)
# Judge status: Accepted
n = int(input())
l = []
for i in range(n):
    sp = input().split()
    l.append([sp[0], int(sp[1]), i+1])

s = sorted(l, key=lambda i: (i[0], -i[1]))

for i in range(n):
    print(s[i][2])
# Judge status: Accepted
# 81

# libraries
from itertools import combinations

# input
N = int(input())

# solve
l = list(range(1,10))
if N in [i*j for i, j in combinations(l+l, 2)]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def main():
    S = input()
    work, temp = [0] * 2019, 0
    work[0] = 1
    a = 1
    for s in S[::-1]:
        temp += int(s) * a
        work[temp%2019] += 1
        a *= 10
        a %= 2019
    print(sum([w*(w-1)//2 for w in work]))
main()
# Judge status: Wrong Answer
K,A,B= map(int, input().split())

if A + 2 >= B or K < A + 2:
    print(K + 1)

else:
    K -= A - 1
    q, m = divmod(K, 2)
    print((B - A) * q + A + m)
# Judge status: Accepted
S = input()
f = 0
for i in range(len(S)-1):
  if S[i] == S[i+1]:
    f = 1
if f == 0:
  print('Good')
else:
  print('Bad')
# Judge status: Accepted
N = int(input())
S = input()

L = 0
cnt = 0
for i in range(N):
    if S[i] == '(':
        cnt += 1
    else:
        if cnt > 0:
            cnt -= 1
        else:
            L += 1

print('('*L + S + ')'*cnt)
# Judge status: Wrong Answer
s=str(input())
x=len(s)
a=s.count("dream")
b=s.count("dreamer")
c=s.count("erase")
d=s.count("eraser")
e=s.count("dreameraser")
a-=b
c-=d
if 5*(a+c)+6*(b+d)-e==x:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
a, b, c = map(int, input().split())
cnt = 0
while a%2==0 and b%2==0 and c%2==0:
  if a==b==c:
    print(-1)
    exit()
  a, b, c = b//2+c//2, a//2+c//2, a//2+b//2
  cnt += 1
print(cnt)
# Judge status: Accepted
A, B, C, K = map(int, input().split())

ans = A - B
if abs(ans) <= 10 ** 18:
    if K % 2 == 0:
        print(ans)
    else:
        print(ans * -1)
else:
    print("Unfair")
# Judge status: Wrong Answer
x, k, d = map(int, input().split())  # x現在地,k 移動回数,D移動できる距離
a = x // d  # 移動できる回数
b = x % d  # 移動した特のあまり
if k <= a:  # 移動する回数がkより大きいとき
    x = abs(x) - abs(k*d)
else:
    k = k - a  # ここで最短
    if k % 2 == 0:
        x = abs(x) - abs(a * d)
    else:
        x = abs(x) - abs(a * d)
        x = abs(x) - abs(d)

print(abs(x))
# Judge status: Accepted
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	n=II()
	for i in range(10**10):
		if (i*(i+1))//2>=n:
			print(i)
			exit()




if __name__ == "__main__":
	main()
# Judge status: Wrong Answer
s = input()
n = len(s)


for i in range(2**(n-1)):
  ans = int(s[0])
  f = s[0]
  for j in range(n-1):
    if i & (1<<j):
      f += '+'
      ans += int(s[j+1])
    else:
      f += '-'
      ans -= int(s[j+1])
    f += s[j+1]
    
if ans == 7:
  print(f + '=7')
  exit()
# Judge status: Accepted
ans_word = "keyence"

s = input()
flag = False
if s == ans_word:
    flag = True
else:
    for i in range(len(s)-1):
        for j in range(i+1, len(s)):
            if s[:i] + s[j:] == ans_word:
                flag = True
                break
        if flag:
            break

if flag:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
max_num = 0
for num in A:
  if num > max_num:
    max_num = num

border = A.index(max_num)
height = []
before_h = A[0]
for h in A[:border]:
  if before_h <= h:
    height.append(0)
    
  elif before_h > h:
    height.append(before_h-h)
  before_h = h

for h in A[border:]:
  height.append(max_num-h)

print(sum(height))
# Judge status: Accepted
import sys
n,m=map(int,input().split())
l=[0]*n
o=0
for i in sys.stdin:
  s,c=map(int,i.split())
  if s==1 and c==0 and n!=1:
    o=-1
    break
  elif l[s-1]==0 or l[s-1]==c:
    l[s-1]=c
  else:
    o=-1
    break
if o==0:
  if l[0]==0 and n>1:
    l[0]=1
  o=''.join([str(i) for i in l])
print(o)
# Judge status: Accepted
x, a, b = map(int, input().split())
if abs(x-a)<=abs(x-b):
    print("A")
else:
    print("B")
# Judge status: Wrong Answer
n = int(input())
s=[]
for x in range(n):
    s.append(input())
a={"AC":0, "WA":0,"TLE":0,"RE":0}
for x in s:
    print(x)
    a[x]+=1
print("AC x %s" % a["AC"])
print("WA x %s" % a["WA"])
print("TLE x %s" % a["TLE"])
print("RE x %s" % a["RE"])
# Judge status: Wrong Answer
s = list(input())

flag = 0
pos_a, pos_z = 1, 1
length = 0

for i, ltr in enumerate(s):
  if ltr == 'A':
    pos_a = i
    flag = 1
  elif ltr == 'Z' and flag == 1:
      pos_z = i
      if pos_z - pos_a > length:
        length = pos_z - pos_a
      else:
        flag = 0

print(length)
# Judge status: Wrong Answer
s = input()[::-1]
mod = 2019
cnt = [0] * mod
x = 1
cnt[0] = 1
total = 0
for s in s:
    total = int(s) * x
    total %= mod
    cnt[total] += 1
    x *= 10

ans = sum(i*(i-1)//2 for i in cnt)
print(ans)
# Judge status: Wrong Answer
k=int(input())
s=[]
s.append(7%k)
for i in range(1,k):
    s.append((s[i-1]*10+7)%k)
    if s[i]==0:
        print(i+1)
        exit()
print(-1)
# Judge status: Accepted
N = int(input())
Ali = list(map(int,input().split()))
s = 0

for i in range(N):
  s ^= Ali[i]
  
for i in range(N):
  print(s^Ali[i],end = " ")
  
print("")
# Judge status: Accepted
k = int(input())
a, b = map(int, input().split())
for i in range(a, b+1):
    if not i % k: print("OK"); break
else: print("NG")
# Judge status: Accepted
n = int(input())
ab = []

ans = 0
for i in range(n):
    a, b = map(int, input().split())
    ab.append([a, b])

ab = ab[::-1]

ans = 0
for i in range(n):
    a, b = ab[i]
    a += ans
    if b == 1 or a % b == 0:
        continue
    elif b > a:
        ans += b - a
    else: 
        ans += b - (a % b)

print(ans)
# Judge status: Accepted
nums = list(map(int, input().split()))
nums.sort()
if nums == [5, 5, 7]:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

flg = False
for y in range(N-M+1):
  for x in range(N-M+1):
    res = True
    for i in range(M):
      if A[y+i][y+i:y+i+3] != B[i][i:i+3]: res = False
    if res: flg = True
    if flg: break
  if flg: break

print("Yes" if flg else "No")
# Judge status: Wrong Answer
a, b = map(int, input().split())

s = 0
for i in range(1, 1000):
    s += i
    if a < s:
        print(s - a)
        break
# Judge status: Wrong Answer
W, a, b = map(int, input().split())
print(max(0, max(a, b) - min(a, b)+W))
# Judge status: Accepted
import statistics
n = int(input())
a = [int(i) for i in input().split()]

m = int(((sum(a)/n)*2 + 1) //2)
# m = statistics.mean(a)
# m = int(m) + 1 if m % 1 > 0.5 else int(m)
r = 0
for i in a:
  r += (i - m)**2
  
print(r)
# Judge status: Wrong Answer
n, l = map(int, input().split())
a = sorted([input() for i in range(n)])
print(a)
# Judge status: Accepted
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())
    lines = ["".join(sorted(line.rstrip())) for line in sys.stdin.readlines()]

    ret = 0
    sortedlines = {}
    for n in range(N):
        item = lines[n]
        if item in sortedlines:
            sortedlines[item] += 1
            ret += sortedlines[item]
        else:
            sortedlines[item] = 0

    print(ret)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
import math
a, b = map(int, input().split())
print(math.ceil(a+b))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
kabu = 0
total = 1000

A1 = []
for i in range(1, N):
    a = A[i] - A[i-1]
    A1.append(a)
A1.append(A1[N-2])

for i in range(N):
    if A1[i] > 0:
        b = total // A[i]
        total -= A[i] * b
        kabu += b
    elif A1[i] < 0:
        total += kabu * A[i]
        kabu = 0
    else:
        continue
    #print(total, kabu)
total += kabu * A[N-1]
print(total)
# Judge status: Wrong Answer
n = int(input())
a = n // 100
b = n % 100
check = a > 20 or b / 5 < a
print("1" if check else "0")
# Judge status: Accepted
K = int(input())

def main(K):
  cnt = 1
  amari = 0
  while True:
    amari *= 10
    amari += 7
    amari %= K
    if amari == 0:
      return cnt
    else:
      cnt += 1
  

if K % 2 == 0 or K % 5 == 0:
  print(-1)
else:
  print(main(K))
# Judge status: Wrong Answer
n, k = map(int,input().split())
A = list(map(int,input().split()))

ind = A.index(1)
ans = 0
if n==k:
    print(1)
    exit()
if ind != 0:
    ans += -(-ind//(k-1))
if ind != n-1:
    ans += -(-(n-1-ind)//(k-1))

print(ans)
# Judge status: Accepted
n = int(input())
t, a = map(int, input().split())
li = list(map(int, input().split()))
nl = [0] * n
for i in range(n):
    nl[i] = abs(t - li[i] * 0.006 - a)
print(nl.index(min(nl))+1)
# Judge status: Accepted
N,X=list(map(int, input().split()))
L=list(range(X-N+1,X+N))
print(*L)
# Judge status: Accepted
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for i in range(0, A+1, 1):
  for j in range(0, B+1, 1):
    for k in range(0, C+1, 1):
      if 500 * i + 100 * j + 50 * k == X:
        ans += 1
        
print(ans)
# Judge status: Wrong Answer
import statistics
from collections import deque

d = deque()

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

print(d)

for i in range(a):
  b = d.pop(0)
  print(statistics.median(d))
  d.append(b)
#  print(d)
# Judge status: Accepted
import numpy as np

N, L = map(int, input().split())

taste = np.arange(1, N+1) + L -1
min_ind = np.argmin(np.abs(taste))

mask_1 = np.ones(N, dtype=bool)
mask_1[min_ind] = False

ans = np.sum(taste[mask_1])

print(ans)
# Judge status: Accepted
n=int(input());s=input();b=0;w=a=s.count('.')
for c in s:b+=(x:=c=='#');w-=(x<1);a=min(a,b+w)
print(a)
# Judge status: Accepted
def resolve():
    '''
    code here
    '''
    N, P = [int(item) for item in input().split()]
    As = [int(item)%2 for item in input().split()]

    is_all_even = True
    for item in As:
        if item == 1:
            is_all_even = False
    
    res = 0
    if is_all_even:
        if P == 0:
            res = 2 ** N
        else:
            res = 0
    else:
        res = 2**(N-1)
    
    print(res)

if __name__ == "__main__":
    resolve()
# Judge status: Accepted
def main():
    A=int(input())
    B=int(input())
    for i in range(1,4):
        if i not in (A,B):
            print(i)
            return
main()
# Judge status: Wrong Answer
import sys

input = sys.stdin.readline


def main():

    # print(ord("A"))
    # print(ord("Z"))

    SS =[]
    N =int(input())
    S =input()
    for i in range(len(S)):
        temp = ord(S[i]) + N
        temp = (temp-65) % 26 + 65
        SS.append( chr(temp))



    for i in SS:
        print(i,end="")





if __name__ == "__main__":
    main()
# Judge status: Accepted
n,m = map(int,input().split())
ls = [[] for _ in range(n+1)]
di = []
for i in range(m):
    a,b = map(int,input().split())
    ls[a].append([b,i+1])
for j in range(n+1):
    if ls[j] != []:
        ls[j].sort(key=lambda x :x[0])
        for k in range(len(ls[j])):
            di.append([ls[j][k][1],str(10**12+j*10**6+k+1)[1:]])
di.sort(key=lambda x :x[0])
for l in range(m):
    print(di[l][1])
# Judge status: Accepted
print('ABD' if 999 < int(input()) else 'ABC')
# Judge status: Accepted
a,b=map(int,input().split())

# aをずっと足していくパターン
i1=b-a if a<b else float("inf")

# aをずっと足していき、-aにするパターン
i2=-a-b+1 if -a>=b else float("inf")

# -aにしてずっと足していくパターン
i3=a+b+1 if -a<=b else float("inf")

# -aにしてずっと足して、さらに -aにするパターン
i4=a-b+2 if a>=b else float("inf")


print(min(i1,i2,i3,i4))
# Judge status: Accepted
x, y, a, b, c = map(int, input().split())

p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

# step1: sort red/green apples in descending order
p.sort(reverse=True)
q.sort(reverse=True)

# step2:clip necessary apples
p = p[:x]
q = q[:y]

# step3: sort red/green apples in ascending order
p.sort()
q.sort()

# step4: sort non-color apples in descending order
r.sort(reverse=True)

# step5:swap apples to eliminate the least delicious apple
d = []

d.extend(p)
d.extend(q)
d.extend(r)
d.sort(reverse=True)

print(sum(d[: x + y]))
# Judge status: Accepted
import heapq
#解説の方法
N,M = map(int,input().split())
AB = [[] for _ in range(10**5+1)]#報酬振り込み日数ごとに報酬を格納
for _ in range(N):
    a,b = map(int,input().split())
    AB[a].append(-b)
q = []
heapq.heapify(q)
ans =0
for i in range(1,M+1):
    for b in AB[i]:
        heapq.heappush(q,b)
    if len(q)>0:
        ans += -heapq.heappop(q)
print(ans)
# Judge status: Accepted
N, K, *A = map(int, open(0).read().split())

x = A[:]

for _ in range(min(50, K)):
    y = [0] * (N + 1)
    for i in range(N):
        y[max(0, i - x[i])] += 1
        y[min(N, i + x[i] + 1)] -= 1
        
    for i in range(N):
        y[i + 1] += y[i]
        
    x = y[:]
        
    
print(*x[:-1])
# Judge status: Accepted
N,A,B=map(int,input().split())
S=' '+input()
AB=A+B
j=1
num=0
for i in range(1,N+1):
    if S[i]=='b' and num<AB and j<=B:
        print('Yes')
        j+=1
        num+=1
    elif S[i]=='a' and num<AB:
        print('Yes')
        num+=1
    else:
        print('No')