peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
K = int(input())
import queue
q = queue.Queue()
for i in range(1,10):
    q.put(i)

for i in range(K-1):
    num = q.get()
    if num%10!=0:
        q.put(10*num+(num%10)-1)
    q.put(num*10)
    if num%10!=9:
        q.put(10*num+(num%10)+1)
    
        
print(q.get())
# Judge status: Accepted
a = sorted(list(map(int, input().split())))
if a[0]==a[1]==a[2]:print(1)
elif a[0]==a[1] or a[1]==a[2]:print(2)
else :print(3)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b0=[]
b1=[]
for i in range(n):
  if i%2==0:
    b0.append(a[i])
  else:
    b1.append(a[i])
if n%2!=0:
  b0=list(reversed(b0))
  b=b0+b1
  print(' '.join(map(str, b)))
else:
  b1=list(reversed(b1))
  b=b1+b0
  print(' '.join(map(str, b)))
# Judge status: Wrong Answer
n, a, b = map(int, input().split())

ans = min(n-b, n-a)
if (b-a)%2:
    print(ans)
else:
    print(min(ans, (b-a)//2))
# Judge status: Accepted
n = int(input())
ls = list(map(int,input().split()))
ls.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if (ls[i]+ls[j] > ls[k]) and ls[i]!=ls[j] and ls[i]!=ls[k] and ls[k]!=ls[j] :
                ans += 1
print(ans)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
k=int(input())
i=0
while a>=b:
    b*=2
    i+=1
  

while b>=c:
        c*=2
        i+=1

if a<b and b<c:
    print("Yse")
else:
    print("No")
# Judge status: Accepted
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
cnt_A = Counter(A)

A_ = sorted([[k, v] for k, v in cnt_A.items() if v >= 2], reverse=True)

if len(A_) == 0:
    print(0)
elif A_[0][1] >= 4:
    print(A_[0][0] ** 2)
else:
    print(A_[0][0] * A_[1][0])
# Judge status: Accepted
N = int(input())

L = [2, 1]
for i in range(2, N+1):
    L.append(L[i-2] + L[i-1])

print(L[-1])
# Judge status: Wrong Answer
n = int(input())
x = [list(map(int, list(input().split()))) for i in range(n)]

x.sort()

ans = n
i = 0
while i != len(x) - 1:
    maxs = x[i][0] + x[i][1]
    ming = x[i + 1][0] - x[i + 1][1]
    if maxs > ming:
        del x[i + 1]
        ans -= 1
        i -= 1
    i += 1

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

for i in range(1,N):
    S1 = sum(W[:i])
    S2 = sum(W)-S1
    if abs(S1-S2) < ans:
        ans = abs(S1-S2)

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

ac = [False] * N
wa = [0] * N
for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if S == 'AC':
        ac[p] = True
    else:
        if not ac[p]:
            wa[p] += 1

a = 0
b = 0
for i in range(N):
    if ac[i]:
        a += 1
        b += wa[i]
print(*[a, b])
# Judge status: Accepted
n=int(input())
csf=[list(map(int,input().split())) for i in range(n-1)]
c=[csf[i][0] for i in range(n-1)]
s=[csf[i][1] for i in range(n-1)]
f=[csf[i][2] for i in range(n-1)]

for i in range(n-1):
  now=s[i]+c[i]
  for j in range(i+1,n-1):
    if now<=s[j]:
      now=s[j]+c[j]
    else:
      while (now-s[j])%f[j]!=0:
        now+=1
      now+=c[j] 
  print(now)
print(0)
# Judge status: Wrong Answer
from collections import deque

S = deque(input().strip())
q = int(input())

rev = True
for _ in enumerate(range(q)):
    query = input().split()
    if query[0] == '1':
        rev = not rev
    else:
        if (query[1] == '1') ^ rev:
            S.appendleft(query[2])
        else:
            S.append(query[2])
S = S if not rev else reversed(S)
print(*S, sep='')
# Judge status: Accepted
a,b,c,k=map(int,input().split())
if abs(a-b)<10**18:
    if k%2==0:
        print(a-b)
    else:
        print(b-a)
else:
    print("Unfair")
# Judge status: Wrong Answer
str1, str2 = [s for s in input().split()]
a = str1*int(str2)
b = str2*int(str1)
sort = [a, b]
sorted(sort)
print(sort[0])
# Judge status: Accepted
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

res = 0
tmp1 = 0
for i in range(n):
    tmp1 += a1[i]
    tmp2 = 0
    for j in range(i, n):
        tmp2 += a2[j]
    res = max(res, tmp1+tmp2)

print(res)
# Judge status: Accepted
import math

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

num = a/b
print(math.ceil(num))
# Judge status: Wrong Answer
s = str(input())
start = 0
end = 0
for i in range(len(s)):
    if s[i]=='A' and start==0:
        start = i
    if s[-(i+1)]=='Z' and end==0:
        end = len(s)-i
print(end-start)
# Judge status: Wrong Answer
def tmp(n):
    return n * (n - 1) / 2


def main():
    line = input().strip()
    n, m = [int(v) for v in line.split(' ')]

    ans_n = tmp(n) if n > 1 else 0
    ans_m = tmp(m) if m > 1 else 0
    ans = ans_n + ans_m
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
s = str(input())
alist = ["dream", "dreamer", "erase", "eraser"]
ans = False

def backwards(x):
  return x[::-1]
s = backwards(s)
alist = [backwards(i) for i in alist]

t = ""
start = 0
for i in range(len(s)+1):
  if s[start:i] in alist:
    t+=s[start:i]
    start = i
if s==t:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
def nck(n, k, mod):
    result = 1
    for i in range(n - k + 1, n + 1):
        result = result * i % mod
    tmp = 1
    for i in range(1, k + 1):
        tmp = tmp * i % mod
    return result * pow(tmp, mod - 2, mod) % mod


def main():
    n, a, b = map(int, input().split())
    mod = 10 ** 9 + 7
    print((pow(2, n, mod) - nck(n, a, mod) - nck(n, b, mod) - 1) % mod)


if __name__ == '__main__':
    main()
# Judge status: Accepted
S = input()
T = input()
alp = "abcdefghijklmnopqrstuvwxyz"
d = {s: None for s in alp}
e = {s: None for s in alp}
for s, t in zip(S, T):
    if d[t] is None:
        d[t] = s
    elif d[t] != s:
        print("No")
        exit()
    if e[s] is None:
        e[s] = t
    elif e[s] != t:
        print("No")
        exit()
print("Yes")
# Judge status: Accepted
n, r = map(int, input().split())
print(r if n >= 10 else 100 * (10 - n) + r)
# Judge status: Wrong Answer
s,w=input().split()
if s<=w:
    print("unsafe")
else:
    print("safe")
# Judge status: Accepted
n=int(input())

ans=0

if n%2==0:
  st=10
  d=1
  while st<=n:
    ans+=(n//st)
    st*=5
  print(ans)
else:
  print(ans)
# Judge status: Accepted
MOD = 1000000007
# f(x) = f(x - 1) + f(x - 2)の場合のdp
def f_dp(x, a):
    dp = [0] * (x + 1)
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1
    for i in range(2, x + 1):
        if i not in a:
            dp[i] = dp[i - 1] + dp[i -2]
    return dp[n] % MOD

if __name__ == "__main__":
    n, m = map(int, input().split())
    a = set([int(input()) for i in range(m)])

    dp = f_dp(n, a)
    print(dp)
# Judge status: Accepted
A, B = map(int,input().split())
print(A * B)
# Judge status: Wrong Answer
k, s = map(int, input().split())

c = int(s / 3)
 
ans = (k - c) 

if ans == 0:
  print(1)
else:
  print(ans*3)
# Judge status: Accepted
#!/usr/bin/env python

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

d = {}
cnt = 0 
for i in range(n):
    if a[i] not in d:
        d[a[i]] = 1 
    else: 
        d[a[i]] += 1

for key in d.keys():
    if d[key] != key:
        if d[key] < key:
            cnt += d[key]
        else:
            cnt += d[key]-key

print(cnt)
# Judge status: Wrong Answer
n = int(input())
arr = list(map(int,input().split()))

N = pow(10,9)+7
def gcd(a,b):
    if a>b:return gcd(b,a)
    while b!=0:
        nb = b%a
        a = b
        b = nb
    return a

def lcm(a,b):
    tmp =  (a*b)//gcd(a,b)
    return tmp

hcm = arr[0]
for i in range(1,n):
    hcm = lcm(hcm,arr[i])

res = 0
for num in arr:
    res += (hcm//num)
    

print(res)
# Judge status: Accepted
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

print(int(min(K,N)*X+max((N-K),0)*Y))
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
ans=0
f=[1]*(N+1)
las=A[N]
g=[las]*(N+1)
flag=1
for i in range(0,N):
    f[i+1]=2*(f[i]-A[i])
for i in range(N,0,-1):
    g[i-1]=g[i]+A[i-1]
print(f,g)
for i in range(N+1):
    if min(f[i],g[i])<=0:
        flag=0
        break
    ans=ans+min(f[i],g[i])
if g[N]>f[N]:
    flag=0
if flag==0:
    print(-1)
else:
    print(ans)
# Judge status: Accepted
l = sorted(list(map(int, input().split())))
print(((l[2]+1)//2-l[2]//2)*l[0]*l[1])
# Judge status: Wrong Answer
W,H,x,y = map(int,input().split())

flag = 1 if x==y else 0

print(str(W*H/2) + " " + str(flag))
# Judge status: Accepted
n,m = map(int,input().split())
lm,rm = map(int,input().split())
for i in range(m-1):
    l,r = map(int,input().split())
    lm = max(lm,l)
    rm = min(rm,r)
print(max(rm-lm+1,0))
# Judge status: Accepted
import sys
import math
import numpy as np
input = sys.stdin.readline

N = int(input())
X = math.ceil(N / 1.08)
if math.floor(X * 1.08) == N:
    print(X)
else:
    print(':(')
# Judge status: Accepted
A,B,C,K = list(map(int, input().split()))

if K%2==0:
    print(A-B)
else:
    print(B-A)
# Judge status: Accepted
n,m=map(int,input().split())
l=[]
for _ in range(m):
    l.append(list(map(int,input().split())))
a=[0]*(n+1)
a[1]=1
c=[1]*(n+1)
for i in range(m):
    c[l[i][0]]-=1
    c[l[i][1]]+=1
    if a[l[i][0]]:
        a[l[i][1]]=1
    if c[l[i][0]]==0:
        a[l[i][0]]=0
print(a.count(1))
# Judge status: Accepted
s = input()

n = len(s)
i = 0
ans = 1
pre = None
while i < n-1:
    if pre is None:
        pre = s[i]
    if pre == s[i+1]:
        pre = s[i+1:i+3]
        i += 2
    else:
        pre = s[i+1:i+2]
        i += 1
    if i < n:
        ans += 1


print(ans)
# Judge status: Accepted

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

if len(set([A, B, C])) == 2:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
A, B, M = map(int, input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
X = 0
Y = 0
C = 0
Min = min(a) + min(b)

for _ in range(M):
    x, y, c = map(int, input().split())
    if c > C and (a[x-1]+b[y-1]) - c > 0:
        X = x - 1 
        Y = y - 1
        C = c

res = (a[X] + b[Y]) - C
if Min < res:
    print(Min)
    exit()
print(res)
# Judge status: Wrong Answer
N = int(input())
T = [int(input()) for _ in range(5)]

dp = [5,0,0,0,0,0]
ans = 0
while dp[-1]<5:
    for i in range(4,-1,-1):
        if dp[i]>0:
            if dp[i]>=T[i]:
                dp[i] -= T[i]
                dp[i+1] += T[i]
            else:
                dp[i+1] += dp[i]
                dp[i] = 0
    ans +=1
print(ans)
# Judge status: Accepted
a=int(input())
b=int(input())
h=int(input())
k=(a+b)*h//2
print(k)
# Judge status: Accepted
import math

num, dist = map(int, input().split())
count = 0
for i in range(0,num):
    x, y = map(int, input().split())
    distance = math.sqrt(x**2 + y**2)
    if distance <= dist:
        count += 1

print(count)
# Judge status: Wrong Answer
n, m = map(int, input().split())
x = (m-2*n)//4
print(min(n+x, (m-2*x)//2))
# Judge status: Accepted
a,b,c=sorted(map(int,input().split()))
print(c*10 + a + b)
# Judge status: Accepted
n,m = map(int,input().split())

m = m//2

if n >= m:
    print(m)
else:
    print(n+(m-n)//2)
# Judge status: Wrong Answer
k, n = map(int,input().split())
a = list(map(int,input().split()))
a.append(k)

ans = 0
max_dis = 0

for i in range(n):
    dis = a[i+1] - a[i]
    max_dis = max(max_dis,dis)
    ans += dis
    
ans -= max_dis
print(ans)
# Judge status: Wrong Answer
N = int(input())
print((N*800)-((N//15)*20))
# Judge status: Accepted
S = input()
print("Yes" if len(set(S))==3 else "No")
# Judge status: Accepted
n = int(input())
s = input()

r_cnt, l_cnt = 0, 0
for i in range(n):
    if s[i] == "(":
        r_cnt += 1
    else:
        if r_cnt == 0:
            l_cnt += 1
        else:
            r_cnt -= 1

print(l_cnt * "(" + s + r_cnt * ")")
# Judge status: Accepted
import math
x, k, d = map(int,input().split())
x = abs(x)
if x > k * d:
    print(x - k * d)
else:
    time = math.floor(x/d)
    x -= time * d
    k -= time
    if k % 2 == 0:
        print(x)
    else:
        print(d - x)
# Judge status: Accepted
n,m = map(int,input().split())
print('Yes' if n == m else 'No')
# Judge status: Accepted
from fractions import gcd
from collections import Counter
a,b=map(int,input().split())
g=gcd(a,b)
L=[]
for i in range(2,int(g**0.5)+1):
    while g%i==0:
        g//=i
        L.append(i)
if L==[]:
    L.append(g)
else:
    if g!=1:
        L.append(g)
LC=Counter(L)
r=len(LC)
if 1 not in LC.keys():
   r+=1
print(r)
# Judge status: Accepted
A,B,C,D = map (int, input ().split ())
if A < C:
  X = C
else:
  X = A
if B < D:
  Y = B
else:
  Y = D
if Y-X < 0:
  print (0)
else:
  print (Y-X)
# Judge status: Wrong Answer
import itertools
import math
n=int(input())
X=[list(map(int,input().split())) for _ in range(n)]
P=[i for i in range(n)]
total=0
for j in itertools.permutations(P,n):
  candi=list(j)
  for k in range(len(candi)-1):
    dis1=(X[candi[k]][0]-X[candi[k+1]][0])**2
    dis2=(X[candi[k]][1]-X[candi[k+1]][1])**2
    total+=(dis1+dis2)**(1/2)
    print(candi,total)
print(total/math.factorial(n))
# Judge status: Accepted
n = int(input())
pp = []
pm = []
mp = []
mm = []

for i in range(n):
    x, y = list(map(int, input().split()))
    pp.append(x + y)
    pm.append(x - y)
    mp.append(-x + y)
    mm.append(-x - y)

max_pp = max(pp)
min_pp = min(pp)
max_pm = max(pm)
min_pm = min(pm)
max_mp = max(mp)
min_mp = min(mp)
max_mm = max(pm)
min_mm = min(pm)

max_val = max(max_pp - min_pp, max_pm - min_pm, max_mp - min_mp, max_mm - min_mm)
print(max_val)
# Judge status: Accepted
d=int(input())
print('Christmas' if d==25 else 'Christmas Eve' if d==24 else 'Christmas Eve Eve' if d==23 else 'Christmas Eve Eve Eve')
# Judge status: Wrong Answer
import sys
import time
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())

groups = []

def dfs(s, n):
    if n == N:
        print(s)
        return True
    # for ns in 'abcdefghijklmnopqrstuvwxyz'[:n+1]:
    for i, ns in enumerate('abcdefghij'[:n+1]):
        dfs(s+ns, max(i, n+1))

dfs('', 0)
# Judge status: Accepted
import sys
input = sys.stdin.readline

H, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
dp = [10**18]*(H+1)
dp[0] = 0

for i in range(H):
    for A, B in AB:
        j = min(H, i+A)
        dp[j] = min(dp[j], dp[i]+B)

print(dp[H])
# Judge status: Accepted
n=int(input())
ans=n-1
for i in range(2,int(n**0.5)*2):
    if n % i == 0:
        tmp=i+n//i-2
        ans=min(ans,tmp)
print(ans)
# Judge status: Accepted
a = int(input())
ans = a + a**2 + a**3
print(ans)
# Judge status: Accepted
N = int(input())

num = [[0] * 10 for i in range(10)]

for i in range(1, N+1):
    top = int(str(i)[0])
    end = int(str(i)[-1])
    num[top][end] += 1

count = 0
for i in range(10):
    for j in range(10):
        count += num[i][j] * num[j][i]

print(count)
# Judge status: Accepted
A, B = map(int, input().split())
if (A-2)%13 > (B-2)%13:
  print('Alice')
elif (A-2)%13 < (B-2)%13:
  print('Bob')
else:
  print('Draw')
# Judge status: Wrong Answer

import math
import itertools
import statistics
#import collections
n = int(input())
s = input()

amari = 0
plus = 0

for i in range(n):
    if s[i]==")":
        plus += 1
    else:
        if plus <= 0:
            amari +=1
        else:
            plus -= 1

for i in range(plus):
    print("(", end="")

print(s, end="")

for i in range(amari):
    print(")", end="")
# Judge status: Accepted
N,M,Q=map(int,input().split())
L=[]
for i in range(Q):
  L.append(list(map(int,input().split())))
  L[i][0]-=1
  L[i][1]-=1
#print(L)
import itertools
R=list(range(1,M+1))#ここで変数Lを使っていた
A=list(itertools.combinations_with_replacement(R,N))
ans=0
#print(L)変数を上書きしていた！！！！！
for i in A:
  tmp=0  
  for a,b,c,d in L:
    if (i[b]-i[a])==c:
      tmp+=d
  ans=max(ans,tmp)
print(ans)
# Judge status: Wrong Answer
import math

A, B, N = map(int, input().split())

max_result = -10 ** 12

N = min(N, 10 ** 8)
for x in range(0, N+1):
    tmp = math.floor(A * x / B) - (A * math.floor(x / B))
    max_result = max(max_result, tmp)

print(max_result)
# Judge status: Accepted
N, M, X, Y = map(int, input().split())
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))

is_war = True

import numpy as np

for Z in range(X+1, Y+1):
    if np.all(np.array(x_list) < Z) and np.all(np.array(y_list) >= Z):
        is_war = False
        break
    
if is_war:
    print("War")
else:
    print("No War")
# Judge status: Accepted
L = int(input())
ans = (L / 3) * (L / 3) * (L / 3)
print(ans)
# Judge status: Accepted
N,K = (int(i) for i in input().split())
P = [int(i) for i in input().split()]
P_expect_sum = [0 for i in range(N)]

P_pred = 0
for i in range(N):
  P_expect = (1+P[i])/2
  P_expect_sum[i] = P_pred + P_expect
  P_pred = P_expect_sum[i]

ans = P_expect_sum[K-1]
for i in range(K-1,N):
  ans = max(ans, P_expect_sum[i] - P_expect_sum[i-K])
print(ans)
# Judge status: Accepted
import heapq
n,m=map(int, input().split())
A=[-1*int(i) for i in input().split()]
heapq.heapify(A)

while m>0:
    x = heapq.heappop(A)
    x*=-1
    x//=2
    x*=-1
    heapq.heappush(A, x)
    m-=1
print(-1*sum(A))
# Judge status: Accepted
L,R=map(int,input().split())
if R-L>=2019:
    ans=0
else:
    ans=2018
    for i in range(L,R):
        for t in range(i+1,R+1):
            Z=(i*t)%2019
            ans=min(Z,ans)
print(ans)
# Judge status: Accepted
K, X = map(int, input().split())
print("Yes" if K * 500 >= X else "No")
# Judge status: Accepted
N = int(input())
p = N
s = []
abt = "abcdefghijklmnopqrstuvwxyz"
ans = ""

while p > 0:
   p -= 1
   s.append(p % 26)
   p //= 26

for i in s[::-1]:
    ans += abt[i]

print(ans)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        n,m,x,y=map(int, input().split())
        lx=list(map(int,input().split()))
        ly=list(map(int,input().split()))
        xmax=max(lx)
        ymin=min(ly)
        for i in range(x+1,y+1):
            if xmax<i and ymin >=i:
                return 'No War'
        return 'War'
    print(main())
resolve()
# Judge status: Accepted
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N,K = MI()
A = LI()

print((N-1+K-2)//(K-1))
# Judge status: Accepted
n,k=map(int,input().split())
p=list(map(int,input().split()))

b=[0]
for i in range(1,n+1):
 b.append(p[i-1]+b[i-1])

mm=0
inx=-1
for i in range(len(b)-k):
 if b[i+k]-b[i]>=mm:
  inx=i
  mm=b[i+k]-b[i]


ans=0
for j in range(inx,inx+k):
  ans+=((p[j]*(p[j]+1))*0.5)*(1/p[j])

print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
a = list(map(int, input().split()))
cnt = [0]*9

for ai in a:
    i = min(ai//400, 8)
    cnt[i] += 1

m = 0
M = 0

for i in range(8):
    if cnt[i]>0:
        m += 1
        M += 1

if cnt[-1]>0:
    if m==0:
        m = 1
    
    M += cnt[-1]

print(m, M)
# Judge status: Wrong Answer
a,b,c,d=map(int,input().split());print(min(b,d)-max(a,c))
# Judge status: Wrong Answer
a = input()
e = input()
b = len(a)
f = 0
for i in range(b) :
    c = a[i]
    d = e[i]
    if not c == d :
        print("No")
        f = 1
if f == 0 :
    print("Yes")
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))

X = 0

for x in a:
    X ^= x

ans = [X ^ a[i] for i in range(N)]

print(*ans)
# Judge status: Accepted
import sys
import math
 
def main():
    N = int(input())
    xy=[]
    for _ in range(N):
        xy.append(list(map(int,input().split())))
 
    sqs=[]
    for i in range(0,len(xy)):
        for j in range(i+1,len(xy)):
            sqs.append(math.sqrt((xy[i][0]-xy[j][0])**2 + (xy[i][1]-xy[j][1])**2))
 
    print(sum(sqs) * 2 / N)
 
main()
# Judge status: Accepted
# -*- coding: utf-8 -*-

str_1,str_2 = input().split()
str_1_count,str_2_count = input().split()
del_str = input()
if del_str == str_1:
    str_1_count = int(str_1_count) - 1
else:
    str_2_count = int(str_2_count) - 1

print(str(str_1_count) +" " + str(str_2_count))
# Judge status: Wrong Answer
a,b=input().split()
print("TNeos"[a!=b::2])
# Judge status: Accepted
n = int(input())
s = input()
t = input()
flag = False
for i in range(n):
    if s[i:] == t[:n-i]: 
        flag = True
        break
print(i+n if flag else n*2)
# Judge status: Accepted
import numpy
N = int(input())
a = numpy.array([int(i) for i in input().split()])
min =  10**9+1
minus = 0
total = 0
for i in a :
    if i < 0 :
        minus += 1
    if abs(i) < min :
        min = abs(i)
    total += abs(i)
#    print(i,min,total)
if minus %2 == 0 :
    print(total)
else :
    print(total-min*2)
# Judge status: Wrong Answer
a = int(input())
b = int(input())
h = int(input())
x = (a+b)/2
print(x*h)
# Judge status: Wrong Answer
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
a = list(set(s+t))
ans = {}
for i in a:
    ans[i] = 0
for i in s:
    ans[i] += 1
for i in t:
    ans[i] -= 1

print(max(ans.values()))
# Judge status: Accepted
th,ta,ah,aa=map(int,input().split(" "))
#print(th,ta,ah,aa)
#print((ah-1)//ta,(th-1)//aa)
if (ah-1)//ta > (th-1)//aa:
  print("No")
elif (ah-1)//ta <= (th-1)//aa:
  print("Yes")
# Judge status: Wrong Answer
A,B,C,D = map(int,input().split())

if B < C or D < A:
    print(0)
elif A <= C and D <= B:
    print(D-C)
elif C < A and B < D:
    print(B-A)
elif C < B:
    print(B-C)
elif A < D:
    print(D-A)
# Judge status: Accepted
A, B, C = map(int, input().split())

if C >= A and C <= B :
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
#4問目
N = int(input())
a = list(map(int, input().split()))
#足していった配列を用意する
Sum = 0
Min = 2 * 10**5
SumArray = [0] * N
for i in range(N):
    Sum += a[i]
    SumArray[i] = Sum
#仕切りを用意して，左側をすぬけくん，右側をアライグマのカードとして差分を計算する
for i in range(N-1):
    temp = abs(SumArray[i] - (SumArray[N-1] - SumArray[i]))
    if temp < Min:
        Min = temp
        
print(Min)
# Judge status: Accepted
val = [111*i for i in range(1, 10)]
N = int(input())
while not N in val:
  N += 1
print(N)
# Judge status: Accepted
N = int(input())
arr = list(map(int, input().split()))
for i in arr:
    if i % 2 == 0:
        if i % 3 != 0 and i % 5 != 0:
            print('DENIED')
            exit()
print('APPROVED')
# Judge status: Wrong Answer
A, B, C = map(int, input().split())
print(B // A)
# Judge status: Accepted
X = list(map(lambda x:int(x), input().split()))
n = X[0]
k = X[1]
p = list(map(lambda x:int(x), input().split()))

p.sort()

s = 0
for i in range(k):
  s += p[i]
  
print(s)
# Judge status: Accepted
import math
N, M = map(int, input().split())
B = tuple(int(a) // 2 for a in input().split())

x = B[0]
for i in range(1, N):
    x = (x * B[i]) // math.gcd(x, B[i])

for b in B:
    if (x // b) % 2 == 0:
        print(0)
        break
else:
    ans = (M // x) - (M // (2 * x))
    print(ans)
# Judge status: Wrong Answer
n = input()
from collections import Counter
c = Counter(n)
for k, v in c.items():
    if v >= 3:
        print('Yes')
        break
else:
    print('No')
# Judge status: Accepted
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    S = list(map(int, input().split()))
    result = 0
    count = 2
    while all([s % count == 0 for s in S]):
        count *= 2
        result += 1

    print(result)


if __name__ == "__main__":
    main()
# Judge status: Accepted
def main():
    n = input()
    p = [int(x) for x in input().split()]
    c = 0
    for i in range(1, len(p)-1):
        if p[i-1] < p[i] < p[i+1] or p[i-1] > p[i] > p[i+1]:
            c += 1
    print(c)

main()
# Judge status: Accepted
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [float("inf") for _ in range(N)]
dp[0] = 0
for i in range(N - 1):
    for j in range(1, min(K + 1, N - i)):
        dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
print(dp[N - 1])
# Judge status: Accepted
x = int(input())

y = (x-1)//11
z = (x-1)%11

u = 2*(y+1)

if z < 6:
    u -= 1
    

print(u)
# Judge status: Wrong Answer
s=input()
ans=0
rain=[0]
for i in range(len(s)):
    if s[i]=="R":
        ans+=1
    else:
        rain.append(ans)
        ans=0
print(max(rain))