peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import math
n,m=map(int,input().split())
mod=10**9+7
a=math.factorial(n)*math.factorial(m)
if abs(n-m)==0:
    print(2*a%mod)
    exit()
elif abs(n-m)>1:
    a=0
print(a%mod)
# Judge status: Accepted
x, y = map(int, input().split())
if (x + y) % 3 != 0:
    print(0)
else:
    n = (x+y) // 3
    nx = x - n
    ny = y - n
    if (nx < 0 ) or (ny < 0):
        print(0)
    else:
        mod = 10 **9 +7
        fac = [1] * 1000000
        for i in range(1,n+1):
            fac[i] = fac[i-1] * i % mod
        print(fac[n] * pow(fac[nx], mod-2, mod) * pow(fac[ny], mod-2, mod) % mod)
# Judge status: Accepted
y,m,d = map(str, input().split('/'))
ymd = int(y+m+d)
if ymd <= 20190430:
    print('Heisei')
else:
    print('TBD')
# Judge status: Wrong Answer
# 入力 : 数字3つ
a, b, c = map(int, input().split())

# 整数 C が A 以上 かつ B 以下であるかを判定してください。
if a <= c <= b :
    print("YES")
else :
    print("NO")
# Judge status: Accepted
a,b,c = (int(x) for x in input().split())
if a+b>c:
  print("No")
elif 4*a*b < (c-a-b)**2:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
#081_C
from collections import Counter
n,k=map(int,input().split())
a=Counter(input().split())

if len(a)<=k:
    print(0)
else:
    c=a.most_common()[::-1]
    print(sum([c[i][1] for i in range(len(a)-k)]))
# Judge status: Accepted
d = dict()

n = int(input())
a = [int(x) for x in input().split()]

for x in a:
  d[x - 1] = d.setdefault(x - 1, 0) + 1
  d[x] = d.setdefault(x, 0) + 1
  d[x + 1] = d.setdefault(x + 1, 0) + 1

print(sorted(d.items(), key=lambda x : x[1],  reverse=True)[0][1])
# Judge status: Wrong Answer
n, k, s = map(int, input().split())
arr = [s]*k + [s+1]*(n-k)

print(*arr)
# Judge status: Accepted

s = input()
t = input()
n = len(s)

a = [0 for i in range(26)]
b = [0 for i in range(26)]

for i in range(n):
    a[ord(s[i])-ord("a")] += 1
    b[ord(t[i])-ord("a")] += 1
#print(a)
#print(b)

a.sort()
b.sort()

if a == b:
    print("Yes")
else:
    print("No")

"""
from collections import Counter
S=input()
T=input()
SS=Counter(S)
TT=Counter(T)
if sorted(SS.values())==sorted(TT.values()):
  print('Yes')
else:
  print('No')

"""
# Judge status: Wrong Answer
# input
N, K, Q = map(int, input().split())
points = {}
for i in range(1, N + 1):
    points[i] = K

for q in range(Q):
    A = int(input())

    # check
    for k in points.keys():
        if k != A:
            points[k] -= 1

# output
for p in points:
    if p > 0:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
from itertools import accumulate


def main():
    n, k = map(int, input().split())
    a = [int(i) for i in input().split()]
    ini = [0] * n
    fin = [n] * n
    for c in range(min(k, 45)):
        b = ini.copy()
        for i, ai in enumerate(a):
            b[max(i - ai, 0)] += 1
            if i + ai + 1 < n:
                b[i + ai + 1] -= 1
        a = list(accumulate(b))
    print(*a)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
import collections
s = input()
cnt = collections.Counter(s)
cnt = cnt.most_common()
# print(cnt)
if len(s) == 1:
    print('NO')
    exit()
if len(cnt) == 2:
    if len(s) == 2:
        print('YES')
    else:
        print('NO')
    exit()

if cnt[0][1] > cnt[-1][1] + 1:
    print('NO')
else:
    print('YES')
# Judge status: Accepted
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]

for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M

for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)

print(ans)
# Judge status: Accepted
s = input()
c = 0
for i in range(len(s) // 2):
    if s[i] != s[len(s) - i - 1]:
        c += 1
print(c)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=sum(b)
for i in range(n-1):
    if a[i+1]-a[i]==1:
        ans+=c[a[i]-1]
print(ans)
# Judge status: Accepted
X = int(input())
ans=8-(int((X-400)/200))

print("{}".format(ans))
# Judge status: Wrong Answer
n=int(input())
count=0
keep=10*100
tempkeep=0
import math
for i in range(0,5):
  a=int(input())
  if i==0:
    drop=0
  else:
    drop=1
  if a<keep:
    count+=math.ceil(n/a)-tempkeep+drop
    tempkeep=math.ceil(n/a)
    keep=a
  else:
    count+=1
print(count)
# Judge status: Accepted
n,k = map(int, input().split())
s = input()

ans = ''
i = 1
for abc in s:
  if i == k:
    ans += abc.lower()
  else:
    ans += abc
  i += 1

print(ans)
# Judge status: Accepted
N,T=map(int,input().split())
a=[]
for i in range(N):
    c,t=map(int,input().split())
    if t<=T:
        a.append(c)
print('TLE' if len(a)==0 else min(a))
# Judge status: Wrong Answer
A, B = map(int, input().split())
S = input()
for i in range(A):
    if not S[i].isdecimal():
        print('No')
        exit()
if S[A] != '-':
        print('No')
        exit()
for i in range(A+1, B+1):
    if not S[i].isdecimal():
        print('No')
        exit()
print('Yes')
# Judge status: Accepted
N,K = map(int,input().split())
x = [int(i) for i in input().split()]
a=[]
for i in range(N-K+1):
  left =x[i]
  right =x[i+K-1]
  p1 = abs(left) + abs(right-left)
  p2 = abs(right) + abs(right-left)
  p = min(p1,p2)
  a.append(p)
  
  
print(min(a))
# Judge status: Accepted
N = int(input())
a_list = [int(a) for a in input().split()]
count = 0
for n in range(N):
    if (n + 1) % 2 == 1 and a_list[n] % 2 == 1:
        count += 1
print(count)
# Judge status: Accepted
n, k = map(int, input().split())
scores = list(map(int, input().split()))
right = k
left = right - k + 1

while right < n:
    if scores[right] > scores[left-1]:
        print("Yes")
    else:
        print("No")

    right += 1
    left += 1
# Judge status: Accepted
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

nums = np.array(read().split(), np.int64)

A = nums[:9]

for x in nums[10:]:
    A[A == x] = 0

def check(A):
    for i, j, k in ((0, 1, 2), (3, 4, 5), (6, 7, 8), (0, 3, 6), (1, 4, 7),
                    (2, 5, 8), (0, 4, 8), (2, 4, 6)):
        if A[i] == A[j] == A[k] == 0:
            return True
    return False

print('Yes' if check(A) else 'No')
# Judge status: Accepted
S = input()
d = []
for s in S:
    if s == '0' or s == '1':
        d.append(s)
    else:
        d = d[:-1]

print(*d, sep='')
# Judge status: Wrong Answer
a,b,k = map(int,input().split())
if k<=a:
  a -= k
else:
  b -= (k-a)
  a = 0
print(a,b)
# Judge status: Wrong Answer
N=int(input())
list=[]
for i in range(N):
  s=sorted(input())
  list.append(s)
list=sorted(list)
n=list[0]
m=0
for j in range(1,N):
  if n==list[j]:
    m+=1
    n=list[j]
print(m)
# Judge status: Accepted
n, m, x, y = map(int,input().split())

x_n = list(map(int,input().split()))
y_m = list(map(int,input().split()))

x_n_max = max(x_n)
y_m_min = min(y_m)


if x > y:
    x_n_max = 1000000000000000000000

ans = 0
for z in range(x+1,y+1):
    if x_n_max < z and y_m_min >= z:
        print('No War')
        ans = -1
        break


if ans == 0:
    print('War')
# Judge status: Accepted
import sys
import numpy as np

# import os
# path = os.getcwd()
# path = os.path.join(path,"input.txt")
# sys.stdin = open(path)

input = sys.stdin.readline
N,K = map(int,input().split())
h = [int(input()) for _ in range(N)]
h.sort()
ans = float("inf")
for i in range(N-K+1):
    ans = min(ans,h[i+K-1]-h[i])
print(ans)
# Judge status: Wrong Answer
ans=0
x=0
for i in input():
  if i=="I":x+=1
  else:x-=1
  ans=max(x,ans)
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
flag = 1
for num in A:
    if num % 2== 0:
        if num % 3 ==0 or num % 5 ==0:
            continue
        else:
            flag =0

if flag == 1:
    print("APPROVED")
else:
    print("DENIED")
# Judge status: Wrong Answer
S = input()
A="S[0]"+"S[1]"+"S[2]"
print("A")
# Judge status: Accepted
n = int(input())
l = list(map(int, input().split()))

l.sort()
l.reverse()
if l[0] < sum(l[1:]):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
x,y = map(int,input().split())
ans = -1
i = 1

while True:
    a = (x*i) % y
    if a != 0:
        ans = x*i
        break
    else:
        ans = -1
        break

print(ans)
# Judge status: Accepted
n = int(input())
answer = sum([(n - 1) // a for a in range(1, n)])
print(answer)
# Judge status: Accepted
def main():
    n=int(input())
    num=[i*(i+1)//2 for i in range(4473)]
    ans=[]
    while n>0:
        for i in range(1,4473):
            if num[i]>=n:
                ans.append(i)
                n-=i
                break
    for i in range(len(ans)):
        print(ans[len(ans)-1-i])
if __name__=="__main__":
    main()
# Judge status: Wrong Answer
#68B Break Number
n=int(input())
maxnum=0
maxtrial=2
while maxtrial<n:
    maxtrial*=2
print(int(maxtrial/2))
# Judge status: Accepted
import fractions

def lcm(x,y):
  return x * y // fractions.gcd(x,y)


mod = 10**9+7


N = int(input())

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

B = 0
for i in A:
    B += pow(i,mod-2,mod)
    B %= mod

g = 1

for i in range(N):
    g = lcm(g,A[i])

print (g * B % mod)
# Judge status: Accepted
x = int(input())

money = 100
t=0
while True:
    if money < x:
        t += 1
        money *= 1.01
        money = int(money)
    else:
        break
print(t)
# Judge status: Accepted
N = int(input())
print(1-N//2/N)
# Judge status: Wrong Answer
N,K = map(int,input().split())
h = []
ans = 10**10
for i in range(N):
    tmp = int(input())
    h.append(tmp)
h = sorted(h)[::-1]
for i in range(N-K):
    ans = min(h[i]-h[i+K-1],ans)
print(str(ans))
# Judge status: Accepted
N,K = map(int,input().split())
S = input()
ans = S[:K-1] + chr((ord(S[K-1]) + 32)) +S[K:]
print(ans)
# Judge status: Accepted
a = input()
s = input()

if a >= '3200':
    print(s)    
if a < '3200':
    print('red')
# Judge status: Accepted
n, d = map(int, input().split())
lst = [[int(j) for j in input().split()] for i in range(n)]
count = 0
for x in lst:
  distance = (x[0]**2 + x[1]**2)**0.5
  if distance <= d:
    count += 1
print(count)
# Judge status: Accepted
from math import floor
a,b=map(int, input().split())

for i in range(1200):
    if floor(i*0.08)==a and floor(i*0.1)==b:
        print(i)
        break
else:
   print(-1)
# Judge status: Accepted
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
  temp=list(map(str,input()))
  a.append(temp)
for i in range(m):
  temp=list(map(str,input()))
  b.append(temp)
temp=[]
ans=0
for i in range(n-m+1):
  for j in range(n-m+1):
    count=0
    for k in range(m):
      for l in range(m):
        if b[k][l]==a[k+i][l+j]:
          count=count+1
    if count==m*m:
      ans=1
if ans==1:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500 + j*100 + k*50 == x:
                cnt += 1

print(cnt)
# Judge status: Accepted
n,m=map(int,input().split())
if n==m==1:
  print(1)
elif min(n,m)==1:
  print(max(n,m)-2)
else:
  print((n-2)*(m-2))
# Judge status: Accepted
h = int(input())
ans = (1 << h.bit_length()) - 1
print(ans)
# Judge status: Accepted
#n=int(input())
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
for i in range(n-k):
    if a[i]<a[i+k]:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
ans = 0
n = int(input())
for i in range(1,n+1):
    if i%3 != 0 and i%5 != 0:
        ans += i
print(ans)
# Judge status: Accepted
n = int(input())

for i in range(21):
    for j in range(15):
        if 4 * i + 7 * j == n:
            print('Yes')
            exit()

print('No')
# Judge status: Accepted
n=list(input())
print('Yes' if n[0]==n[1]==n[2] or n[3]==n[1]==n[2] or  n[0]==n[2]==n[3]==n[1] else 'No')
# Judge status: Accepted
x,k,d=map(int, input().split())
if abs(k*d)>abs(x):
    if k%2==0:
        a=x%(2*d)
        print(min(abs(a),abs(a-2*d)))
    else:
        a=x%(2*d)
        print(min(abs(a-d),abs(a+d)))
else:
    print(abs(x)-abs(k*d))
# Judge status: Wrong Answer
A,B,C=map(int,input().split())

if A+2*B>=C:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N = int(input())
A = tuple(map(int, input().split()))

money = 1000
stock = 0
for i in range(N - 1):
    if A[i] < A[i + 1]:
        stock += money // A[i]
        money %= A[i]
    else:
        money += stock * A[i]
        stock = 0
money += stock * A[-1]
stock = 0
print(money)
# Judge status: Accepted
n = int(input())
ans = 0
for a in range(1,n+1):
    y = n//a
    ans+=(y*(y+1)*a)//2
print(ans)
# Judge status: Accepted
s=str(input())
count=0
if s[0]=='A':
  count+=1
for i in range(2,len(s)-1):
  if s[i].count('C')==1:
    count+=1
s=s.replace('A','').replace('C','')
if s.islower()==True:
  count+=1
if count==3:
  print('AC')
else:
  print('WA')
# Judge status: Accepted
import numpy as np


def solve():
    dists = np.zeros(n, dtype=int)
    for i in range(n):
        dists[i] = abs(a[(i+1)%n]-a[i%n])
        dists[i] = min(dists[i], k-dists[i])
    ans = k - np.max(dists)
    print(ans)
    return




k, n = [int(i) for i in input().split(" ")]
a = [int(i) for i in input().split(" ")]
solve()
# Judge status: Accepted
N = int(input())
cnts = [[0] * 10 for _ in range(10)]
ans = 0
for i in range(N + 1):
    if i % 10 == 0:
        continue
    s = str(i)
    cnts[int(s[0])][int(s[-1])] += 1

for i in range(N + 1):
    if i % 10 == 0:
        continue
    s = str(i)
    ans += cnts[int(s[-1])][int(s[0])]

print(ans)
# Judge status: Accepted
s=input()
a=s.count('a')
b=s.count('b')
c=s.count('c')
if abs(a-b)<2 and abs(a-c)<2 and abs(b-c)<2: print('YES')
else: print('NO')
# Judge status: Accepted
n=int(input()) 
while(1): 
	bool_1=True 
	for i in range(2,int(n**0.5//1)):   
		if n % i ==0:  
			bool_1=False 
			break     
	if bool_1:break 
	n+=1 
print(n)
# Judge status: Accepted
n, k = map(int, input().split())
h = sorted([int(input()) for _ in range(n)], reverse=True)

m = float('inf')
for i in range(n-k+1):
  m = min(m, h[i]-h[i+k-1])

print(m)
# Judge status: Accepted
n = int(input())
INF = 10 ** 9
dp = [INF] * (n + 1)
dp[0] = 0
for i in range(n):
  dp[i+1] = min(dp[i+1], dp[i] + 1)
  v = 6
  for j in range(1, 8):
    if i+1 >= v:
      dp[i+1] = min(dp[i+1], dp[i+1-v] + 1)
    v *= 6
  v = 9
  for j in range(1, 7):
    if i+1 >= v:
      dp[i+1] = min(dp[i+1], dp[i+1-v] + 1)
    v *= 9
print(dp[n])
# Judge status: Accepted
n, a, b, c, d = map(lambda x: int(x)-1, input().split())
s = input()


def can_reach(x, y):
    return '##' not in s[x:y+1]


def can_jump(x, y):
    return '...' in s[x-1:y+2]


if can_reach(a, c) and can_reach(b, d):
    if c < d:
        print('Yes')
    else:
        if can_jump(b, d):
            print('Yes')
        else:
            print('No')
else:
    print('No')
# Judge status: Accepted
n, m = map(int, input().split())
a = list(map(int, input().split()))

num1 = a[0]
num2 = 0
while num1 % 2 == 0:
    num1 //= 2
    num2 += 1
gc = 2 ** num2

b = []
for i in a:
    if i % gc != 0 or (i // gc) % 2 == 0:
        print(0)
        exit()
    else:
        b.append(i // gc)

from fractions import gcd
lcm = 1
for i in b:
    lcm = (lcm * i) // gcd(lcm, i)

ans = m // (lcm * (gc // 2))
ans = (ans + 1) // 2
print(ans)
# Judge status: Accepted
A,B = map(int,input().split())

num = 1
res = 0
while num < B:
  res += 1
  num += A-1

print(res)
# Judge status: Wrong Answer
import sys
n = list(map(int, input().split()))

if n[0] == 1 or n[1] == 1:
    print(0)

if n[0] % 2 == 0:
    print(int((n[0]*n[1])/2))
    sys.exit()
else:
    if n[1] % 2 == 0:
        print(int((n[0]*n[1])/2))
        sys.exit()
    else:
        a = ((n[0]-1)*n[1])/2
        b = n[1] - int(n[1]/2)
        print(int(a+b))
        sys.exit()
# Judge status: Accepted
S = list(input())
S_rev = list(reversed(S))
N = len(S)
if S != S_rev:
  print('No')
else:
  S1 = S[:int((N-1)/2)]
  S2 = S[int((N+1)/2):]
  S1_rev = list(reversed(S1))
  S2_rev = list(reversed(S2))
  if S1==S1_rev and S2 == S2_rev:
    print('Yes')
  else:
    print('No')
# Judge status: Accepted
from math import floor

a, b = [int(i) for i in input().split()]
for i in range(1, 1011):
    if floor(i * 0.08) == a and floor(i * 0.1) == b:
        print(i)
        exit()
print(-1)
# Judge status: Wrong Answer
n=int(input())
l=[]
c=0
for i in range(n):
    l.append(list(map(int,input().split())))
for i in range(n):
    a,b=l[-1-i][0],l[-1-i][1]
    if b==1:
        continue
    c+=b-((a+c)%b)
print(c)
# Judge status: Accepted
n=int(input())
a=list(map(int, input().split()))
ans=0

s=sum(a)

for i in range(1,len(a)+1):
    ans += a[i-1] * (s-a[i-1])
    s = s-a[i-1]
    ans = ans % (10 ** 9 + 7)

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

for i in range(n,10*n):
    num=set(list(map(int,str(i))))
    if i>=n and len(D&num)==0:
        print(i)
        exit()
# Judge status: Wrong Answer
A, B, C = map(int, input().split())

if (A + 2 * B) >= C:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
S = input("R or S:")
s = list(S)

count = 0
for i in s:
    if i == "R":
        count += 1
    else: count =0
print(count)
# Judge status: Wrong Answer
A = list(map(int, input().split()))
print(int(A[0]/A[1]) + 1)
# Judge status: Accepted
def main():
    n, d = map(int, input().split())

    if n % (2 * d + 1) == 0:
        ans = n // (2 * d + 1)
    else:
        ans = n // (2 * d + 1) + 1

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
#!/usr/bin/env python3
import sys

S = input()
T = input()

ans = 0
for i in range(len(S)):
    if S[i] != T[i]:
        ans += 1

print(ans)
# Judge status: Wrong Answer
from collections import deque
import numpy as np
n, k = map(int, input().split())
An = list(map(int, input().split()))
root = deque([1])
check = np.zeros(n, np.int)
check[0] = 1
i = 0
dup = 1
cnt = 1
for _ in range(n):
    temp = An[i]
    if check[temp-1] == 1:
        dup = temp
        break
    root.append(temp)
    check[temp-1] = 1
    i = temp - 1
    cnt += 1
index = root.index(dup)
if index == cnt - 1:
    print(dup)
else:
    print(root[(k-index) % (cnt-index) + index])
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

ans = (2020202020)**100
sum_A = sum(A)
hoge = 0


for i in range(N-1):
  hoge = hoge + A[i]
  ans = min(ans,(abs(sum_A - (hoge*2))))

print(ans)
# Judge status: Accepted
import math
a,b,n = list(map(int,input().split()))
if b-1>=n:
    x=n
else:x=b-1
print(math.floor(a*x/b)-a*math.floor(x/b))
# Judge status: Accepted
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    A,B,M=map(int,input().split())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))
    L=[list(map(int,input().split())) for i in range(M)]

    ans=min(A)+min(B)

    for l in L:
        ans=min(ans,A[l[0]-1]+B[l[1]-1]-l[2])
    print(ans)


resolve()
# Judge status: Accepted
_, x, *a = map(int, open(0).read().split())
c = 0
for i in sorted(a):
  x -= i
  if x<0:
    break
  c += 1
print(c - (x>0))
# Judge status: Accepted
k = int(input())

odd = 0
even = 0
for i in range(1,k+1):
  if(i%2 == 0):
    even += 1
  else:
    odd += 1
print(odd*even)
# Judge status: Accepted
N,Y = map(int,input().split())

for x in range(N+1):
    for y in range(N+1-x):
        p = x*10000 + y*5000
        if p > Y: break
        rem = Y - p
        z = rem//1000
        if x+y+z == N:
            print(x,y,z)
            exit()
print(-1,-1,-1)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
d=[0]*(10**5+1)
ans=0
for i in range(len(a)):
  if a[i]<=10**5:
    d[a[i]]+=1
for i in range(1,len(d)):
  if d[i]>i:
    ans+=d[i]-i
  elif d[i]<i:
    ans+=d[i]
print(ans)
# Judge status: Accepted
n,a,b=map(int, input().split())

print((b-a)//2 if (b-a)%2==0 else min(a-1,n-b)+1+(b-a-1)//2)
# Judge status: Accepted
def resolve():
    '''
    code here
    '''
    import collections
    N, M = [int(item) for item in input().split()]
    Xs = [int(item) for item in input().split()]
    if N < M:
        Xs.sort()
        ds = [Xs[i] - Xs[i-1] for i in range(1, M)]
        ds.sort()
        # print(ds)
        print(sum(ds[:M-N]))

    else:
        print(0)


if __name__ == "__main__":
    resolve()
# Judge status: Accepted
#!/usr/bin/env python

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

if a%2 == 0 and a == b == c:
    print(-1)
    exit()

ans = 0 
while True:
    if a%2 == 1 or b%2 == 1 or c%2 == 1:
        print(ans)
        exit()
    ta = a 
    tb = b 
    tc = c 
    a = (tb+tc)//2
    b = (tc+ta)//2
    c = (ta+tb)//2
    ans += 1
# Judge status: Accepted
def atc_077a(input_value: str) -> str:
    C1 = input_value[0]
    C2 = input_value[1]

    if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:
        return "YES"
    else:
        return "NO"


C1 = input()
C2 = input()
print(atc_077a([C1, C2]))
# Judge status: Accepted
MOD = 10**9+7

s = int(input())
a = [0]*(s+1)
a[0] = 1
for i in range(3, s+1):
    a[i] = sum(a[:i-2]) % MOD
print(a[s])
# Judge status: Accepted
S = list(input())
T = list(input())
R1 = [-1]*26
R2 = [-1]*26
ans = "Yes"

for i in range(len(S)):
    s = ord(S[i])
    t = ord(T[i])
    if R1[s-97] >= 0:
        if R1[s-97] != t:
            ans = "No"
            break
    else:
        R1[s-97] = t
    if R2[t-97] >= 0:
        if R2[t-97] != s:
            ans = "No"
            break
    else:
        R2[t-97] = s

print(ans)
# Judge status: Accepted
import bisect
import copy
import heapq
import sys
import itertools
import math
from functools import lru_cache
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N, K = read_values()
    A = read_list()
    for i in range(N - K):
        print("Yes" if A[i] < A[i + K] else "No")


if __name__ == "__main__":
    main()
# Judge status: Accepted
w = input()
char_map = { c: 0 for c in w }
for c in w:
    char_map[c] += 1

flag = True
for val in char_map.values():
    if val % 2 != 0:
        flag = False
        break

print('Yes' if flag else 'No')
# Judge status: Accepted
import sys
from collections import Counter
input = sys.stdin.readline

N = int(input())
S = []
S2 = []

for _ in range(N):
    S.append(input().strip())

count = Counter(S)
most = max(count.values())
for key, value in count.items():
    if value == most:
        S2.append([key, value])

S2.sort(key=lambda x:x[0])
for value in S2:
    print(value[0])
# Judge status: Accepted
c = [list(map(int, input().split())) for _ in range(3)]

for i in range(1, 3):
    d = c[i][0] - c[0][0]
    e = c[0][i] - c[0][0]
    for j in range(1, 3):
        if d != c[i][j] - c[0][j]:
            print("No")
            exit()
        if e != c[j][i] - c[j][0]:
            print("No")
            exit()
print("Yes")
# Judge status: Accepted
n, k = map(int, input().split())
a = list(map(int, input().split()))

def check(l):
    cnt = 0
    for _ in a:
        cnt += _ // l
        if _ % l != 0:
            cnt += 1
        cnt -= 1
    if cnt <= k: return True
    else : return False

"""
left: ng
right: ok
"""
def binary(ng, ok):
    while ok - ng > 1:
        mid = (ng + ok) // 2
        if check(mid): ok = mid
        else: ng = mid
    return ok

print(binary(0, max(a)))
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
d = int(input())

if a > b:
  print(b*c+(a-b)*d)
else:
  print(a*c)