peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import math
N, K = map(int,input().split())
print(math.floor(math.log(N, K)) + 1)
# Judge status: Wrong Answer
l,r=map(int,input().split())
l_mod=l%2019
r_mod=r%2019
l_div=l//2019
r_div=r//2019
if l_div<r_div:
  print(0)
else:
  print(l_mod*(l_mod+1))
# Judge status: Wrong Answer
n,m = map(int,input().split())
print(n*(n-1) if n >= m else m*(m-1))
# Judge status: Accepted
n,a,b=map(int,input().split())
print(max(((b*(n-1))+a)-((a*(n-1))+b)+1,0))
# Judge status: Accepted
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N, P = map(int, input().split())
A = list(map(int, input().split()))
o, e = 0, 0
for i in A:
    if i % 2 == 0:
        e += 1
    else:
        o += 1
ans = 0
for i in range(P, o+1, 2):
    ans += comb(o, i)
print(ans * 2 ** e)
# Judge status: Accepted
a, b = map(int, input().split())

def cal(a,b):
    if a < b:
        dist1 = b - a
        dist2 = abs(b + a) + 1
        return min(dist1, dist2)
    elif a > b:
        if a >= 0 and b <= 0:
            return abs(a+b) + 1

        else:
            return a - b + 2

print(cal(a,b))
# Judge status: Wrong Answer
N = int(input())
res = 0
if N % 2 == 0:
  res = N / 2
else:
  res = N // 2 + 1
  
print(res)
# Judge status: Accepted
A, B, C = map(int, input().split())

if A < C < B:
  print("Yes")
elif B < C < A:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
N = int(input())
a_list = list(map(int, input().split()))
cnt = 0
ref_num = 1
if 1 not in a_list:
    print(-1)
    exit()
while True:
  for i in range(len(a_list)):
    if ref_num == a_list[i]:
      red = len(a_list[:i])
      a_list = a_list[i+1:]
      cnt += red
      break
  ref_num += 1
  if a_list == []:
    print(cnt)
    break
# Judge status: Wrong Answer
N = int(input())
s = [int(input()) for i in range(N)]

import collections
c = collections.Counter(s)
print(list(c.values()))
ans_lis = [x for x in list(c.values()) if x %2 != 0]
print(len(ans_lis))
# Judge status: Wrong Answer
n, sum_w = map(lambda x: int(x), input().split())

# goods = list[]
all_weights = []
all_values = []
for _ in range(n):  
    w, v = map(lambda x: int(x), input().split())
    all_weights.append(w)
    all_values.append(v)
    

def max_value(i_item, remaining_weight):
    if i_item == n - 1:
        return 0 if all_values[i_item] < remaining_weight else all_values[i_item]
            
    return max(all_weights[i_item] + max_value(i_item+1, remaining_weight - all_weights[i_item]),
        max_value(i_item+1, remaining_weight))

print(max_value(0, sum_w))
# Judge status: Wrong Answer
a, y = map(int,input().split())
if a >= 13:
  print(y)
elif a <= 12 and a >= 6:
  print(y / 2)
else:
  print(0)
# Judge status: Accepted
import math

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

print(math.ceil(N/(D*2+1)))
# Judge status: Wrong Answer
a, b, c, d=map(int,(input()))
l = [a, b, c, d]

if l.count(a)==l.count(b)==l.count(c)==l.count(d)==1:
    print("Good")
else:
    print("Bad")
# Judge status: Wrong Answer
from collections import Counter
 
N = int(input())
S = {}
for i in range(N):
  S[i] = input()
print(len(Counter(S.keys()).keys()))
# Judge status: Wrong Answer
s=input()
t=input()
if s==t[0:-1]:
  print('yes')
else:
  print('no')
# Judge status: Wrong Answer
if __name__ == '__main__':
    n = int(input())
    list =[0]*86
    list[0]=2
    list[1]=1

    for i in range(2,86):
        list[i]=list[i-1]+list[i-2]

    if n ==86:
        print("939587134549734843")
    else:
        print(list[n-1])
# Judge status: Accepted
s = list(input())
n = len(s)
for i in range(n):
    for j in range(i,n):
        t = s[:i] + s[j:]
        if ''.join(t) == 'keyence':
            print('YES')
            exit(0)
print('NO')
# Judge status: Accepted
N = int(input())
B = [int(x) for x in input().split()]
A = [0 for y in range(N)]
A[0] = B[0]
A[N-1] = B[N-2]
for i in range(1,N-1):
    A[i] = min(B[i-1],B[i])
print(sum(A))
# Judge status: Accepted
N = int(input())
AB = list()
for _ in range(N):
    ab = list(map(int, input().split()))
    ab.reverse()
    AB.append(ab)
AB.sort()
#print(AB)

at = 0
flag = False

for i in range(N):
    bt = AB[i][0]
    at += AB[i][1]
    #print(at, bt)
    if at > bt:
        flag = True
        break

if flag:
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
n, m = map(int,input().split())
x = sorted(list( map(int,input().split())))
if n >= m:
    print(0)
else:
    d = [0]*(m-1)
    for i in range(m-1):
        d[i] = x[i+1] - x[i]
    d.sort(reverse=True)
    if m%2 == 0:
        e = m-n-1
    else:
        e = m-n-2
    print(sum(d) - sum(d[0:e]))
# Judge status: Accepted
S = input()
n, w = S.count('N'), S.count('W')
s, e = S.count('S'), S.count('E')
flag = True
if n == 0 or s == 0:
    if n != s:
        flag = False
if w == 0 or e == 0:
    if w != e:
        flag = False
print('Yes' if flag else 'No')
# Judge status: Accepted
n = int(input())
s = input()
x = 0
m = 0
for i in range(n):
    if s[i] == "I":
        x += 1
    elif s[i] == "D":
        x -= 1
    m = max(m, x)
print(m)
# Judge status: Accepted
def product(a,b):
    return a*b
    
a,b=map(int,input().split())
print(product(a,b))
# Judge status: Accepted
q , h , s , d = map(int,input().split())
n = int(input())
qb = q*8
hb = h*4
sb = s*2
db = d

if min(qb,hb,db,sb) != db:
    print(n*min(q*4,h*2,s))
elif min(qb,hb,db,sb) == db:
    if n % 2 == 0:
        print((n//2)*d)
    elif n % 2 == 1:
        ans = (n//2) * d
        ans += min(q*4,h*2,s)
        print(ans)
# Judge status: Wrong Answer
import math
in_ = list(input().split())
A = int(in_[0])
B = int(float(in_[1]) * 100)
ans = A * B
ans = int(ans / 100)
print(ans)
# Judge status: Wrong Answer
inp = input('enter :')

if len(inp) <= 3:
    print(inp)
else:
    inp = inp[0:3]
    print(inp)
# Judge status: Accepted
def solve():
  N = int(input())
  A = list(map(int, input().split()))
  B = [abs(a) for a in A]
  ans = sum(B)
  under = [a for a in A if a<0]
  if len(under)%2==1:
    ans -= min(B)*2
  return ans
print(solve())
# Judge status: Accepted
a=int(input().strip('\n'))
s=input().strip('\n')
print('red' if a<3200 else s)
# Judge status: Accepted
N, K = map(int, input().split())

N %= K
#print(N, abs(K-N))
print(min(N, abs(K-N)))
# Judge status: Wrong Answer
n = int(input())
w = [int(_) for _ in input().split()]
d = sum(w)

for i in w:
    dd = d - i*2
    if abs(d) > abs(dd):
        d = dd
print(abs(d))
# Judge status: Accepted
n = int(input())
x = int(n / 1.08)

while int(x*1.08) <= n:
    if int(x*1.08) == n:
        print(x)
        break
    else:
        x += 1

if int(x*1.08) > n:
    print(":(")
# Judge status: Accepted
age = int(input())
if age == 7 or age == 5 or age == 3:
	print('YES')
else:
	print('NO')
# Judge status: Accepted
import sys

input = sys.stdin.readline


def main():
    D = int(input())

    if D == 25:
        ans = "Christmas"
    elif D == 24:
        ans = "Christmas Eve"
    elif D == 23:
        ans = "Christmas Eve Eve"
    else:
        ans = "Christmas Eve Eve Eve"

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
a,b=map(int,input().split())
s=input()
print("Yes"if len(s)==a+b+1 and s[a]=="-" else "No")
# Judge status: Wrong Answer
N = int(input())
S = input()
if N%2 == 1:
  print("NO")
else:
  if(S[: N//2] == S[N//2: ]):
    print("YES")
  else:
    print("NO")
# Judge status: Wrong Answer
n, k = map(int, input().split())
a = [int(x) for x in input().split()]

n = 2 * 10**5
k = 2 * 10**5
a = [0] * n

for i in range(min(k, 450)):
    tmp = [0] * (n + 1)
    for j in range(n):
        tmp[max(0, j - a[j])] += 1
        tmp[min(n, j + a[j] + 1)] -= 1
    
    cnt = 0
    for j in range(n):
        cnt += tmp[j]
        a[j] = cnt

for i in range(n):
    print(a[i], end='')
# Judge status: Accepted
import math
A, B, H, M = [int(x) for x in input().split()]
h = 360 * (H + M/60) / 12
m = 360 * M / 60
cos = math.cos(math.radians(abs(h-m)))
ans = math.sqrt(A*A + B*B - 2*A*B*cos)
print(ans)
# Judge status: Accepted
d,n = map(int, input().split())
if d == 0:
    if n != 100:
        print(n)
    else:
        print(101)
    
elif d == 1:
    if n != 100:
        print(n*100)
    else:
        print(10100)
elif d == 2:
    if n != 100:
        print(n*10000)
    else:
        print(1010000)
# Judge status: Accepted
N = int(input())
MOD = 10**9 + 7
_or = 9**N % MOD
_and = 8**N % MOD
wa = ((9**N) * 2 - 8**N) % MOD
ans = (10**N - wa) % MOD
print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
l=[0]*n
for i in range(n):
    l[a[i]-1]=i+1
print(*l)
# Judge status: Accepted
D = int(input())

if D == 25:
  print("Christmas")
elif D == 24:
  print("Christmas Eve")
elif D == 23:
  print("Christmas Eve Eve")
elif D == 22:
  print("Christmas Eve Eve Eve")
# Judge status: Accepted
N = int(input())
A = [-1*int(input()) for _ in range(N)]


def LIS(seq, wider_sense=False):
    from bisect import bisect_left, bisect_right
    f = bisect_right if wider_sense else bisect_left
    N = len(seq)
    INF = 10**18
    dp = [INF] * (N+1)
    for x in seq:
        i = f(dp, x)
        dp[i] = x
    return f(dp, INF-1)


answer = LIS(A, wider_sense=True)
print(answer)
# Judge status: Wrong Answer
a,b,c=list(map(int,input().split()))
n=0
H=[]
while True:
  S=[a,b,c]
  if S in H:
    print("-1")
    exit()
  H.append(S)
  if a%2!=0 and b%2!=0 and c%2!=0:
    print(n)
    exit()
  else:
    A=a/4
    B=b/4
    C=c/4
    a=a/2+B+C
    b=b/2+A+C
    c=c/2+A+B
    n+=1
# Judge status: Wrong Answer
y1_list = list(map(int,input().split()))
y2_list = list(map(int,input().split()))
y3_list = list(map(int,input().split()))
 
a1 = list()
a2 = list()
 
for i in range(3):
    a1.append(y1_list[i] - y2_list[i])
    a2.append(y2_list[i] - y3_list[i])
    
if a1[0] == a1[1] and a1[2] == a1[0]:
    if a2[0] == a1[1] and a2[2] == a1[0]:
        print("Yes")
        
    else:
        print("No")
else:
    print("No")
# Judge status: Accepted
N = int(input())
S = [0]*N
for i in range(N):
    S[i] = input()
A = {}
for s in S:
    if s not in A:
        A[s] = 1
    else:
        A[s] += 1

B = [(a, A[a]) for a in A]
# print(B)
B.sort(reverse=True, key=lambda x: x[1])
# print(B)
count = B[0][1]
ans = []
for b in B:
    if b[1] == count:
        ans.append(b[0])

ans.sort()
for a in ans:
    print(a)
# Judge status: Accepted
C = input()
chars = "abcdefghijklmnopqrstuvwxyz"
ls = list(chars) + list(chars)
dic = {ls[i]:ls[i+1] for i in range(26)}
print(dic[C])
# Judge status: Accepted
import math
x=int(input())
print(int(10-math.floor(x/200)))
# Judge status: Accepted
from itertools import*
_, *d = map(int, open(0).read().split())
*a, s = list(accumulate(d))
print(min(abs(s - x*2) for x in a))
# Judge status: Accepted
a,b = map(int,input().split())
c = input().split()
c = [int(s) for s in c]
c.sort()
x = 0
for i in range(b):
    x = x + c[i]
print(x)
# Judge status: Wrong Answer
print({"Sunny":"Clowdy","Cloudy":"Rainy","Rainy":"Sunny"}[input()])
# Judge status: Accepted
abc = sorted(list(map(int,input().split())))
add = str(abc[2]) + str(abc[1])
print(int(add) + abc[0])
# Judge status: Wrong Answer
h1, m1, h2, m2, k = map(int, input().split())
print(min(0, (h2*60+m2) - (h1*60+m1) - k))
# Judge status: Wrong Answer
A, B, C = map(int, input().split())
# n*B+C = kAとなるnとkが存在するか
# k = (n*B+C)/A (n,kは整数)
# これを満たすnを順番に調べる。A回繰り返せば必ず1周もしくは答え

n = 0
cnts = [0]*A
while True:
    mod = (n*B+C)%A
    if cnts[mod] == 1:
        print('No')
        break
    if mod == 0:
        print('Yes')
        break
    n += 1
    cnts[mod] = 1
# Judge status: Accepted
N, M = map(int ,input().split())

# N + x : M - 2x = 1 : 2
# M - 2x = 2N + 2x
# x = (M - 2N) / 4

if N * 2 >= M:
  print(int(M / 2))
else:
  x = (M - 2 * N) / 4
  N += int(x)
  M -= 2 * int(x)
  print(N)
# Judge status: Accepted
import sys


k = 'abcdefghijklmnopqrstuvwxyz'
alp = {}

for i in k:
    alp[i] = 0


s = input()

for i in s:
    if alp[i] == 0:
        alp[i] = 1
    else:
        print('no')
        sys.exit()

print('yes')
# Judge status: Wrong Answer
H = int(input())
if H == 1:
  ret = 1
else:
  count = 0
  while True:
    if H % 2 == 1:
      H = int(H / 2)
    else:
      H = int(H / 2) - 1
    count += 1
    if H <= 2:
      break
  ret = 2 **( count + 1) - 1
  
print(ret)
# Judge status: Wrong Answer
s=input()
score=0

for i in range(0,int(len(s)/2)):
    if s[i]!=s[len(s)-1-i]:
        score+=1

print(score)
# Judge status: Accepted
s = input()
print(len(s[s.index('A'):s.rindex('Z')+1]))
# Judge status: Accepted
N = int(input())
# 後ろから押していく
A = [0]*N
B = [0]*N
for i in range(N):
    A[i], B[i] = map(int,input().split())
cnt = 0
for i in range(N-1,-1,-1):
    cnt += (B[i]-(A[i]+cnt)%B[i])%B[i]
print(cnt)
# Judge status: Wrong Answer
N, K = map(int, input().split())

if K == 0:
  print(N)
else:
  if N >= K:
    print(N % K)
  else:
    keisan = abs(N - K)
    if keisan > N:
      print(N)
    else:
      print(keisan)
# Judge status: Accepted
N = int(input())
W = list(map(int,input().split()))
diff_min = float('inf')
for T in range(N):
  s1 = 0
  s2 = 0
  for i in range(T+1):
    s1 += W[i]
  for i in range(N-1,T,-1):
    s2 += W[i]    
    
  diff = abs(s1-s2)
  if diff_min > diff:
    diff_min = diff
    
print(diff_min)
# Judge status: Accepted
import math
import fractions
n, m = map(int, input().split())
a = list(map(int, input().split()))
num = 1
cnt = []
for x in a:
    c = 0
    for i in range(int(math.log(x,2))):
        if x>>c&1:
            break
        else:
            c+=1
    cnt.append(c)
if max(cnt) != min(cnt):
    print(0)
else:
    for x in a:
        num = num * (x//2) // fractions.gcd(num, x//2)
    print(m//num-(m//num)//2)
# Judge status: Accepted
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    l = [x - i for i, x in enumerate(a)]
    from collections import Counter
    c = Counter(l)
    ans = 0
    for i in range(n):
        index = -i * 2 - l[i]
        ans += c[index] if index in c else 0
        c[l[i]] -= 1
    print(ans)


if __name__ == '__main__':
    resolve()
# Judge status: Accepted
A, B = map(int, input().split())

import fractions
gcd = fractions.gcd(A, B)
print(A * B // gcd)
# Judge status: Accepted
s = input()
w = {
  'Sunny': 'Cloudy'
  , 'Cloudy': 'Rainy'
  , 'Rainy': 'Sunny'
}
print(w[s])
# Judge status: Accepted
N = int(input())

cnt = 0

for i in range(1,N+1):
  if len(str(i))%2 != 0:
    cnt +=1
    
print(cnt)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = 0
for i in range(n):
  if a[i] <= b[i]:
    cnt += (b[i]-a[i])//2
    continue
  else:
    cnt -= a[i]-b[i]

if cnt >= 0: print("Yes")
else: print("No")
# Judge status: Wrong Answer
import fractions as math
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
    t=1
    for i in numbers:
      t=lcm_base(t,i)
    return t
N=int(input())
A=list(map(int,input().split()))
A=set(A)
tmp=lcm_list(A)
ans=0
for i in A:
  ans+=tmp//i
  ans%=(10**9+7)
print(int(ans))
# Judge status: Wrong Answer
data = list(map(int, input().split()))
if sum(data) % 2 == 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
ans_list = [0 for i in range(10**6 + 1)]
for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      a = x**2 + y **2 + z**2 + x*y + z*y + x*z
      ans_list[a] += 1
      
for i in range(1,n+1):
  print(ans_list[i])
# Judge status: Wrong Answer
import bisect
N=int(input())
A=[]
ans=0
for i in range(N):
    a=int(input())
    A.append(a)
cl=[A[-1]]
ans=1
for i in range(N-1)[::-1]:
    a=A[i]
    if a>=cl[-1]:
        cl.append(a)
        ans+=1
    else:
        b=bisect.bisect_left(cl,a)
        cl[b]=a
print(ans)
# Judge status: Accepted
Ha,Ma,Hb,Mb,K = list(map(int,input().split()))

tmp = (Hb*60 + Mb) - (Ha*60 + Ma)

print(tmp-K)
# Judge status: Accepted
from collections import Counter

n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

c = Counter(a).most_common()[::-1]
res = 0
for i in range(len(c)-k):
    res += c[i][1]

print(res)
# Judge status: Wrong Answer
S = input()
if S[0] == 'A' and S[1] == 'A' and S[2] == 'A':
    print('NO')
elif S[0] == 'B' and S[1] == 'B' and S[2] == 'B':
    print('NO')
else:
    print('YES')
# Judge status: Wrong Answer
N, K = map(int, input().split())
A = list(map(int, input().split()))
pos = 0
for i in range(N):
  if A[i] == 1:
    pos = i
    break
ans = 0
if i <= K:
  ans += 1
  if N > K:
    ans += (N - K + K - 1)//(K - 1)
  print(ans)
  exit()

ans += (i - K + K - 1)//(K - 1)
ans += (N - i + 1 + K - 1)//(K - 1)
print(ans)
# Judge status: Accepted
a, b, c, x, y = map(int, input().split())

ans = 5000*(10**5)*2
for i in range(max(x, y)+1):
    tmp_ans = i*2*c
    if x > i:
        tmp_ans += (x-i)*a
    if y > i:
        tmp_ans += (y-i)*b
    ans = min(ans, tmp_ans)

print(ans)
# Judge status: Accepted
abc = list(map(int,input().split()))
abc.sort(reverse=True) #降順
print(int(str(abc[0])+str(abc[1]))+abc[2])
# Judge status: Wrong Answer
n,m,x=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(n)]
result=-1
for i in range(2**n):
  t=[0]*m
  money=0
  for j in range(n):
    if (i>>j)&1==0:
      continue
    money+=c[j][0]
    for k in range(m):
      t[k]+=c[j][k]
  if all(xx>=x for xx in t):
    if result==-1:
      result=money
    else:
      result=min(result,money)
print(result)
# Judge status: Accepted
s, w =  map(int, input().split())

if s<= w:
    print("unsafe")
else:
    print("safe")
# Judge status: Wrong Answer
N, K = map(int, input().split())
x = list(map(int, input().split()))
Min = 1e10
for i in range(N-K+1):
    Min = min(Min, x[K+i-1]-x[i]+abs(x[i]))
print(Min)
# Judge status: Wrong Answer
n = int(input())
hlist = list(map(int, input().split()))
alist = list(range(1, n+1))

shlist = []
for height in hlist:
    if height < n - 1:
        shlist.append(height)

ans = 0
# The absolute difference of their attendee numbers is equal to the sum of their heights.
for i, h1 in enumerate(shlist):
    for j, h2 in enumerate(shlist):
        if abs(i-j) == h1+h2:
            ans += 1
print(ans//2)
# Judge status: Wrong Answer
X,Y,Z = map(int,input().split())
print("Z X Y")
# Judge status: Accepted
import math
def main():
  a,b,c = list(map(int,input().split()))
  k = int(input())
  if a<b:
    if b<c:
      print(a+b+c*pow(2,k))
    else:
      print(a+b*pow(2,k)+c)
  else:
    if a<c:
      print(a+b+c*pow(2,k))
    else:
      print(a*pow(2,k)+b+c)
main()
# Judge status: Accepted
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

a, b, n = map(int, input().split())
if n >= b-1:
    print((a * (b-1)) // b - a * ((b-1) // b))
else:
    print((a * n) // b - a * (n // b))
# Judge status: Accepted
N, M = map(int, input().split())

cnt = [1 for _ in range(N)]
red = [True] + [False for _ in range(N - 1)]

for _ in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    cnt[x] -= 1
    cnt[y] += 1
    if red[x]:
        red[y] = True
    if cnt[x] == 0:
        red[x] = False

print(sum(red))
# Judge status: Wrong Answer
def solve():
    n = int(input())
    rolls = [list(map(int,input().split())) for i in range(n)]
    for i in range(n-3):
        if rolls[i][0]==rolls[i][1] and rolls[i+1][0]==rolls[i+1][1] and rolls[i+2][0]==rolls[i+2][1]:
                return True

    return False

print("Yes" if solve() else "No")
# Judge status: Wrong Answer
import math
n, x, t = map(int, input().split())
print(math.ceil(x/n)*t)
# Judge status: Accepted
x, y = map(int, input().split())
agroup = [1,3,5,7,8,10,12]
bgroup = [4,6,9,11]
if x in agroup and y in agroup:
    print('Yes')
elif x in bgroup and y in bgroup:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N, Y = map(int,input().split())
A = B = C = -1
for a in range(N+1):
    for b in range(N+1-a):
        c=N-a-b
        if 10000*a+5000*b+1000*c==Y:
            A = a
            B = b
            C = c
            
print(a, b, c)
# Judge status: Wrong Answer
n, k = map(int, input().split())
A = list(map(int, input().split()))


def check(x):
    cnt = 0
    for a in A:
        if a % x == 0:
            cnt += a//x-1
        else:
            cnt += a//x
    return k < cnt


L = 1
R = 10**10
while L != R-1:
    M = (L+R)//2
    if check(M):
        L = M
    else:
        R = M
print(R)
# Judge status: Accepted
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    just, less = 0, INF
    for d in input()[::-1]:
        d = int(d)
        njust = min(just + d, less + d + 1)
        nless = min(just + (10-d), less + (9-d))
        just, less = njust, nless
    print(min(just, less + 1))
resolve()
# Judge status: Wrong Answer
a = int(input())
b = int(input())
c = int(input())
print(c//max(a,b))
# Judge status: Accepted
from math import floor

a, b = [int(i) for i in input().split()]

for i in range(1, 10**5):
    if floor(i*0.08) == a and floor(i*0.1) == b:
        print(i)
        exit()

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

if n[2]>=n[0] and n[2]<=n[1]:
    print('Yes')
    
else:
    print('No')
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
a=sorted(a,reverse=True)
x=a[0]
y=sum(a[1:])
print('Yes' if x<y else 'No')
# Judge status: Wrong Answer

x=int(input())
n = x//100
k = x %100
if n >= 21 :
    print(1)
elif n*1 <= k <= n*5:
    print(1)
else:
    print(0)
# Judge status: Wrong Answer
S1 = input()
S2 = input()
if S1 == S2[::-1]:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import sys

INF = 1001001001

def resolve():
  s, t = input().split()
  a , b = map(int, input().split())
  u = input()
  if (s == u):
    print(a - 1, b)
  else:
    print(a, b - 1)
  return

if __name__ == "__main__":
    resolve()
# Judge status: Wrong Answer
N = int(input())
input_line = list(map(int, input().split(' ')))
ans = 0
for i in range(N):
    if((i*input_line[i])%2 == 1):
        ans += 1
print(ans)
# Judge status: Accepted
#ABC 122 C - GeT AC 18:47
n, q = map(int, input().split())
s = input()
t = [0]*(n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2] == 'AC' else 0)
for i in range(q):
    l,r = map(int, input().split())
    print(t[r-1] - t[l-1])
# Judge status: Wrong Answer
import fractions
N=int(input())
A=list(map(int,input().split()))
A.append(A[0])
ans=0
l=[]
if N==2:
    print(max(A))
    exit()
for i in range(N):
    val=fractions.gcd(A[i],A[i+1])
    l.append(val)

print(l[2])
# Judge status: Wrong Answer
N, K = map(int, input().split())
a = list(map(int, input().split()))
chk = [0] * N
start = -1
ido = [0]
chk[0] = 1
index = 0
cnt = 0
while True:
    index = a[index] - 1
    if chk[index] == 0:
        chk[index] += 1
        cnt += 1
        ido.append(index)
    else:
        start = index
        break

if cnt >= K:
    print(a[ido[K]])
    exit()
tmp = ido.index(start)
ido = ido[tmp:]
K -= tmp
print(ido[K % len(ido)] + 1)
# Judge status: Accepted
from random import randint
for i in range(365):
  print(randint(1,26))
# Judge status: Accepted
n, k = map(int, input().split())
ls = [[int(_) for _ in input().split()] for _ in range(n)]

ls.sort()

ln = 0

for i in range(n):
	ln += ls[i][1]
	if ln >= k:
		print(ls[i][0])
		break
# Judge status: Wrong Answer
from bisect import *
from heapq import *
import math
mod = 10**9+7
N, K = map(int, input().split())
A = list(map(int, input().split()))
ep = 0.0001
l = 0.0
r = 10**9+1
while l+ep < r:
    x = (l+r)/2
    k = 0
    for a in A:
        k += math.ceil(a/x)-1
        if k > K:
            break
    if k <= K:
        r = x
    else:
        l = x
print(math.ceil(l))
# Judge status: Accepted
s = input()
t = input()
for i in range(len(s)):
    if s[i:]+s[:i]==t:
        print('Yes')
        break
else:
    print('No')
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

MOD = 1000000007


def main():
    n, m = [int(i) for i in input().split()]
    a = [int(input()) for _ in range(m)]
    steps = [0] * (n + 1)
    steps[0] = 1

    for now in range(n):
        for next_ in range(now + 1, min(now + 2, n) + 1):
            if next_ not in a:
                steps[next_] += steps[now] % MOD
    print(steps[-1])


if __name__ == '__main__':
    main()