peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N, A, B = map(int,input().split())
S = input()
p = 0
c = B
for e in S:
    if e == "a":
        if p < A+B:
            print("Yes")
            p += 1
        else:
            print("No")
    elif e == "b":
        if p < A+B and c > 0:
            print("Yes")
            p += 1
            c -= 1
        else:
            print("No")
    else:
        print("No")
# Judge status: Accepted
from fractions import gcd
from functools import reduce


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


def solve(string):
    n, m, *a = map(int, string.split())
    l = reduce(lcm, a)
    c = 1
    while a[0] % (2 * c) == 0:
        c *= 2
    for _a in a:
        if _a % c > 0 or not (_a // c) % 2:
            return "0"
    return str(max((m - l // 2) // l + 1, 0))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
# Judge status: Accepted
o = input()
e = input()
for i in range(len(e)):
    print(o[i] + e[i], end = "")
if len(e) < len(o):
    print(o[i + 1])
else:
    print()
# Judge status: Wrong Answer
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
if N < 3:
    print(0)

ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        if L[i] == L[j]:
            continue
        for k in range(j+1, N):
            if L[i] == L[k] or L[j] == L[k]:
                continue
            if L[i] < L[j] + L[k]:
                ans += 1

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

def eucrid(a,b):
  a,b=max(a,b),min(a,b)
  while True:
    if a%b==0:
      return b
    else:
      a,b=b,a%b
m=a[0]
for i in range(n):
  m=m//eucrid(m,a[i])*a[i]
b=0
m=m%mod
for i in a:
  b+=m*pow(i,mod-2,mod)%mod
print(b%mod)
# Judge status: Accepted
A, B, C, D = map(int, input().split())


def gcd(x, y):
    if x > y:
        x, y = y, x
    while y != 0:
        tmp = x % y
        x = y
        y = tmp
    return x
    
A = A - 1
lcm_CD = C * D // gcd(C, D)
cnt_B = B - (B//C + B//D) + (B//lcm_CD)
cnt_A = A - (A//C + A//D) + (A//lcm_CD)

ans = cnt_B - cnt_A
print(ans)
# Judge status: Wrong Answer
X = int(input())
X_ = X % 101
N = int(X / 101)
ans = 0
for i in range(5):
    X_ -= N

if X_ > 0:
    print(0)
else:
    print(1)
# Judge status: Wrong Answer
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A, B, K = input_number_list()
    t = 0
    i = 0
    while t < K:
        i += 1
        t += 1 if A % i == 0 and B % i == 0 else 0
    print(i)


main()
# Judge status: Accepted
#coding:utf-8
import numpy as np
n = int(input())
a = list(map(int, input().split()))
a = np.array(a)
mod = 10**9 + 7
ans = 0
for i in range(60):
    # i桁目の1の数を数える
    cnt_zero = np.count_nonzero(a >> i & 1)
    cnt_one = n - cnt_zero
    # すべての１と０をそれぞれ掛けあわせた総数を、桁ごとに計算
    ans += 2**i * cnt_zero * cnt_one
    ans %= mod
print(ans)
# Judge status: Wrong Answer
s = input()
if s == "SUN":
    print(7)
    exit()
ls = {"MON": 0, "TUE": 1, "WED": 3, "THU": 4, "FRI": 5, "SAT": 6, "SUN": 7}
print(7-ls[s])
# Judge status: Accepted
a=list(map(int, input().split()))
if a.count(5)==2 and a.count(7)==1:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
n = int(input())
h = list(map(int, input().split()))
cnt = 0
l = []
for i in range(n - 1):
    if h[i] < h[i + 1]:
        l.append(cnt)
        cnt = 0
    else:
        cnt += 1
l.append(cnt)
print(max(l))
# Judge status: Accepted
n,a,b=map(int,input().split())
if a>b:
    print(0)
elif a==b:
    print(1)
elif n==1:
    print(0)
else:    
    print(n*b-b+a-n*a+a-b+1)
# Judge status: Accepted
n=int(input())
s=list(input() for i in range(n))
print("AC x ",s.count("AC"))
print("WA x ",s.count("WA"))
print("TLE x ",s.count("TLE"))
print("RE x ",s.count("RE"))
# Judge status: Wrong Answer
def main():
    N = int(input())
    a = list(map(int,input().split()))

    res = 0
    for i in range(N):
        if i % 2 == 1 and a[i] % 2 == 1:
            res += 1
    print(res)

if __name__ == "__main__":
    main()
# Judge status: Accepted
N,M=map(int,input().split())

x=[-1]*N
ok=True
for _ in range(M):
    s,c=map(int,input().split())
    s-=1
    if (s==0 and c==0 and N>1) or x[s]!=-1 and x[s]!=c:
        ok=False
        break
    x[s]=c

if ok:
    ans=0
    for i in range(N):
        if x[i]==-1:
            x[i]=0 if (i>0 or N==1) else 1
        ans=ans*10+x[i]
    print(ans)
else:
    print(-1)
# Judge status: Wrong Answer
import math
x = int(input())
i = 1
print(i)
while True:
  t = math.pow(i, 5)-x
  if t >= 0:
    b = math.pow(t, 1/5)
    if b.is_integer():
      print(str(i) + ' ' + str(int(b)))
      break
  else:
    b = math.pow(-t, 1/5)
    if b.is_integer():
      print(str(i) + ' ' + str(int(-b)))
      break
  i += 1
# Judge status: Accepted
n = int(input())
i = []
for p in range(n):
  i.append(0)
  a = p + 1
  while True:
    if a % 2 != 0:
      break
    else:
      i[p] += 1
      a = a / 2
print(i.index(max(i)) + 1)
# Judge status: Accepted
X, Y = map(int, input().split())
c = Y//X
tmp = 1
for i in range(100):
    if tmp > c:
        break
    tmp *= 2
print(i)
# Judge status: Accepted
def main():
    f = False
    x, y = map(int, input().split())
    for i in range(x+1):
        a, b = i, x-i
        a *= 2
        b *= 4
        if a + b == y:
            f = True
    if f:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()
# Judge status: Accepted
n, k = map(int,input().split())

cnt = 0

for i in range(k, n+2):
    cnt += (n + 1 - i) * i + 1

print(cnt % (10**9 + 7))
# Judge status: Accepted
s = int(input())
mod = 10 ** 9
x = (mod - s % mod) % mod
y = (s+x) // mod
print(0, 0, mod, 1, x,y)
# Judge status: Accepted
n, T = map(int,input().split())
list_c = []
list_t = []
for i in range(n):
    c, t = map(int,input().split())
    if t > T:
        pass
    else:
        list_c.append(c)
        list_t.append(t)
if len(list_t) == 0:
    print('TLE')
else:
    print(min(list_c))
# Judge status: Accepted
import numpy as np
import sys

n,m,x = map(int,input().split())
arr = np.array([list(map(int,input().split())) for i in range(n)])

c = arr.T[0] # c[n-1]まで
a = arr.T[1:].T # a[n-1][m-1]まで


ans = np.inf
for i in range(2**n):
    ability = np.zeros(m, np.int64)
    cost = 0
    for j in range(n):
        if (i>>j)&1: ability += a[j] ; cost += c[j]
    #print(ability, cost)
    if all(i>=x for i in ability): ans = min(ans,cost)

ans = -1 if ans==np.inf else ans
print(ans)
# Judge status: Accepted
h=int(input())
num=1
cnt=0
while h!=1:
    h=h//2
    cnt+=num
    num*=2
cnt+=num
print(cnt)
# Judge status: Accepted
K = int(input())
S = input()

t = ''
if len(S) > K:
    t = '...'

print(S[:K] + t)
# Judge status: Accepted
a,b=map(int,input().split())
c=list(range(b-(a-1),b+(a-1)+1))
d=' '.join(map(str,c))
print(d)
# Judge status: Wrong Answer
X,Y,Z = map(int,input().split())

X = X-Z
i = 0
while X > 0:
    if X > Y:
        X = X-Y
        i += 1
    X = X-Z
    
print(i)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
M = sum(A)

for n in range(N):
  if A[n]>=B[n]:
    A[n]-=B[n]
  else:
    A[n+1] = max(0,A[n+1]+A[n]-B[n])
    A[n] = 0
    
print(M-sum(A))
# Judge status: Accepted
K, X = map(int, input().split(' '))
for i in range(X - K + 1, X + K - 1):
  print('{} '.format(i), end='')
print(X + K - 1)
# Judge status: Accepted
from collections import defaultdict

n = int(input())
d = defaultdict(int)

for _ in range(n):
    a = int(input())
    d[a] += 1

ans = 0
for v in d.values():
    if v % 2 == 1:
        ans += 1

print(ans)
# Judge status: Wrong Answer
a,b,c = map(int,input().split())

list = [a,b,c]
list.sort()

print(10 * c + b + a)
# Judge status: Accepted
a,b=map(int,input().split())
if a>b:
   c=[]
   for i in range(a):
       c.append(str(b))
   d=''.join(c)
else:
    c = []
    for i in range(b):
        c.append(str(a))
    d = ''.join(c)
print(d)
# Judge status: Accepted
N=int(input())
S=list(input())

count=[0]*3
for i in range(N-1,-1,-1):
    if S[i]=="R":
        count[0]+=1
    elif S[i]=="G":
        count[1]+=1
    else:
        count[2]+=1
        
cnt=0
for i in range(1,N//2+1):
    for j in range(N-2*i):
        a,b,c=S[j],S[j+i],S[j+2*i]
        if a!=b and a!=c and c!=b:
            cnt+=1

ans=count[0]*count[1]*count[2]-cnt
print(ans)
# Judge status: Accepted
A, B = map(int, input().split())

if A == B:
    print('Draw')
    exit()
if A == 1:
    print('Alice')
elif B == 1:
    print('Bob')
elif A > B:
    print('Alice')
else:
    print('Bob')
# Judge status: Accepted
N = int(input())
A = [0] + [int(input()) for i in range(N)]

ans = 0
for i in range(1, N+1):
  a = A[i]; pre_a = A[i-1]
  if pre_a == 1 and a >= 1:
    ans += 1
    a -= 1
  ans += a//2
  A[i] = a % 2

print(ans)
# Judge status: Accepted
N = int(input())
A = [int(a) for a in input().split()]
MA = [0] * (N + 2)
MA[0] = 1
ma = 1
for i, a in enumerate(A):
    if a > ma or (a == ma and i < N - 1):
        print(-1)
        exit()
    ma = (ma - a) * 2
    MA[i+1] = ma

ans = 0
s = 0
for i in range(N + 1)[::-1]:
    a = A[i]
    s = min(s + a, MA[i])
    ans += s
print(ans)
# Judge status: Wrong Answer
n = int(input())
a = [int(k) for k in input().split()]
cnt = [0]*(10**5+1)
for i in a:
  cnt[i] += 1
s = cnt[0] + cnt[1] + cnt[2]
ans = 1
for i in range(3,n-2):
  s -= cnt[i-3]
  s += cnt[i]
  #print(s)
  ans = max(s,ans)
print(ans)
# Judge status: Wrong Answer
s=input()
print(len(s[s.find("A"):s.find("Z")+1]))
# Judge status: Accepted
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
print(min(m//2,(n+m//2)//2))
# Judge status: Wrong Answer
n,k,q = map(int,input().split())

S=[0]*n
for i in range(q):
    a = int(input())
    S[a-1]+=1
    
print( S, max(S) )

for i in range(n):
    if S[i]>q-k :
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
N=int(input())
D=list(map(int,input().split()))
layer=[0]*N

mx=0
for item in D:
    layer[item]+=1
    mx=max(mx,item)

if layer[0]>1:
    print(0)
    exit()

ans=1
for i in range(mx):
    ans*=layer[i]**layer[i+1]

print(ans%998244353)
# Judge status: Wrong Answer
import math

K=int(input())
r=0

for i in range(1,K+1):
  for j in range(1,K+1):
    a=math.gcd(i,j)
    for k in range(K+1):
      b=math.gcd(a,k)
      r+=b
print(r)
# Judge status: Accepted
# D - Preparing Boxes

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

ans = [0] * n

for i in range(n)[::-1]:
    tmp = 0
    j = 0
    while i+(i+1)*j<n:
        tmp += ans[i+(i+1)*j]
        j += 1
    if tmp%2==a[i]:
        continue
    else:
        ans[i] = 1

print(sum(ans))
if sum(ans)>0:
    print(' '.join(map(str, [i+1 for i, x in enumerate(ans) if x == 1])))
# Judge status: Accepted
n, x = map(int, input().split())
l = [int(i) for i in input().split()]
p = 0
for i in range(n):
    p += l[i]
    if p > x:
        print(i + 1)
        break
else:
    print(n + 1)
# Judge status: Accepted
s = input()
t = input()

df = 0

for i in range(len(s)):
    if s[i] != t[i]:
        df += 1

print(df)
# Judge status: Accepted
def resolve():
    X, Y = [int(i) for i in input().split()]
    if X % Y == 0:
        print(-1)
    else:
        print(X)

resolve()
# Judge status: Accepted
n = int(input())
h = list(map(int,input().split()))
ans = 0
kar = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        kar += 1
    else:
        if kar >= ans:
            ans = kar
        kar = 0
if kar >= ans:
    ans = kar
print(ans)
# Judge status: Accepted
import sys 

string1 = str(input())
string2 = str(input())

n, m = len(string2), len(string1) 

ans = sys.maxsize 
for i in range(m - n + 1): 
    minRemovedChar = 0 
    for j in range(n): 
        if (string2[j] != string1[i + j]): 
            minRemovedChar += 1
    ans = min(minRemovedChar, ans) 

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

if (a<=b):
    print(a)
elif (a>b):
    print(a-1)
# Judge status: Accepted
D = int(input())
c = list(map(int,input().split()))
last_di = [0] * 26
for d in range(1, D+1):
    s = list(map(int,input().split()))
    satisfaction_list = [0] * 26
    for i in range(26):
        satisfaction_list[i] = c[i] - (d - last_di[i])
    min_index = satisfaction_list.index(min(satisfaction_list))
    print(min_index + 1)
# Judge status: Accepted
a,b,c=map(int, input().split())

if c-(a-b) >= 0:
    print(c-(a-b))
else:
    print(0)
# Judge status: Wrong Answer
s = set(input())
t = set(input())
if len(s) == len(t):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import sys
input = sys.stdin.readline
N = int(input())
B = [int(x) for x in input().split()]

A = []
for i in range(N) :
    if i == 0 :
        Ai = B[0]
    elif i == N-1 :
        Ai = B[i-1]
    else :
        Ai = min(B[i-1], B[i])
    A.append(Ai)

print(sum(A))
# Judge status: Accepted
n, m = map(int, input().split())
counter_list = [0] * (n + 1)
for i in range(m):
    a, b = map(int, input().split())
    counter_list[a] += 1
    counter_list[b] += 1

for i in range(1, n + 1):
    print(counter_list[i])
# Judge status: Wrong Answer
n=int(input())
k,l=2,1
for i in range(n-1):
    k,l=k+l,k
print(l)
# Judge status: Accepted
s=input()
t=input()
l=len(s)
for _ in range(l):
  if s==t:
    print("Yes")
    exit()
  else:
    s=s[-1]+s[:l-1]
print("No")
# Judge status: Wrong Answer
N = int(input())
cs = []
t1, x1, y1 = 0, 0, 0
ans = 'Yes'
for i in range(N):
  t2, x2, y2 = map(int, input().split())
  d = abs(x1-x2) + abs(y1-y2)
  if d == 0 or d > (t2 - t1) or d % 2 != (t2 - t1) % 2:
    ans = 'No'
    break
print(ans)
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**6)

N = int(input())
h = list(map(int, input().split()))
dp = [-1] * (N+1)

def rec(i):
    if i == 0:
        return 0
    if dp[i] != -1:
        return dp[i]
    dp[i] = 2**60 # 十分大きな値
    if i - 1 >= 0:
        dp[i] = min(dp[i], rec(i - 1) + abs(h[i - 1] - h[i]))
    if i - 2 >= 0:
        dp[i] = min(dp[i], rec(i - 2) + abs(h[i - 2] - h[i]))
    return dp[i]

print(rec(N-1))
# Judge status: Accepted
k,n=map(int,input().split())
a=list(map(int,input().split()))
dist=[]
for i in range(n-1):
  dist.append(a[i+1]-a[i])
dist.append(k-a[n-1]+a[0])
print(sum(dist)-max(dist))
# Judge status: Wrong Answer
# 入力
a, b, h = [int(input())for i in range(3)]



# 処理
S =((a + b) * h) / 2



# 出力
print(S)
# Judge status: Accepted
n = int(input())
cnt = 0
for i in range(1,10**5+1):
    if (i <= n) and (len(str(i)) in [1,3,5]):
        cnt += 1
print(cnt)
# Judge status: Wrong Answer
N=20; X=12; T=6
import math
T_total = ( math.ceil( N / X )*T + T )

print (T_total)
# Judge status: Wrong Answer
mod = 10**9+7
n = int(input())
s = input()
dic = [0 for _ in range(26)]
for i in range(n):
    dic[ord(s[i])-97] += 1
dic = [i for i in dic if i > 0]
result = 0
for i in range(1, 2**len(dic)):
    c = 1
    num = i
    for j in dic:
        if num%2==1:
            c *= j
            c %= mod
        num >>= 1
    result += c
print(result)
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
d={}
ans=0
for a in A:
    try:
        d[a]+=1
    except KeyError:
        d[a]=1
    if d[a]>a:
        ans+=1
        d[a]-=1
print(ans)
# Judge status: Accepted
n=int(input())
t=111
c=1
while t<n:
  c+=1
  t=111*c
print(t)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
"""
４の倍数がn//2個以上
or
全部が２の倍数
"""

n2 = 0
n4 = 0

for _a in a:
    if _a%4 == 0:
        n4 += 1
    elif _a%2 == 0:
        n2 += 1

if n4 + n2//2 >= n//2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import math

n = int(input())

print(math.ceil(n/2))
# Judge status: Wrong Answer
from fractions import gcd
n,x=map(int,input().split())
l=list(map(int,input().split()))
a=[]
for i in range(n):
  a.append(abs(l[i]-x))
g=0
for i in range(n-1):
  g=gcd(g,gcd(a[i],a[i+1]))
print(g)
# Judge status: Accepted
n,k=map(int,input().split())
s=input()
c=0
for i in range(n-1):
  if s[i]==s[i+1]:
    c+=1
print(min(n-1,c+2*k))
# Judge status: Wrong Answer
n=int(input())
if n%2==0:
    print((n//2)*(n//2+1))
else:
    print((n//2)**2)
# Judge status: Accepted
print('YNEOS'[int(input()[::2])%4>0::2])
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))
r = 2 * N
ans = 0
a.sort(reverse=True)
if a[0] > 10**9:
    exit()
a_choiced = a[0:r][1::2]
for i in a_choiced:
    ans += i
print(ans)
# Judge status: Accepted
A,B,K=map(int,input().split())
a=max(A-K,0)
k=K-(A-a)
b=max(B-k,0)
print(a,b)
# Judge status: Wrong Answer
s = list(input())
k = int(input())
#print(ord("z"))
for i in range(len(s)):
  if 123 - ord(s[i]) <= k:
    k -= (123 - ord(s[i]))
    s[i] = 'a'
    #print(k)
#print(s, k)
for i in range(1, len(s) + 1):
  if k == 0:
    break
  else:
    if 122 - ord(s[-i]) < k:
      k -= 122 - ord(s[-i])
      s[-i] = 'z'
    else:
      s[-i] = chr(ord(s[-i]) + k)
      k = 0
ans = ""
for i in s:
  ans += i
print(ans)
# Judge status: Accepted
N,K = map(int,input().split())
P = list(map(int,input().split()))
P = sorted(P)
print(sum(P[0:K]))
# Judge status: Accepted
import sys
input  = input().split()

A = int(input[0])
B = int(input[1].replace('.',''))

print((A*B // 100))
# Judge status: Accepted
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

L = [0] * N

for i in range(N):
  L[i] = (1 + p[i]) / 2

ans = 0

k = 0
for i in range(K):
  k += L[i]

ans = k
for i in range(K, N):
  k += L[i] - L[i - K]
  ans = max(ans, k)

print(ans)
# Judge status: Wrong Answer
N = int(input())
s = input()
t = input()
sr = s[::-1]
if s== t:
    print(s)
else:
    for i in range(N):
        if sr[i] != t[i]:
            break
    print(2*N-i)
# Judge status: Accepted
import math
H, A = map(int, input().split())
print(math.ceil(H / A))
# Judge status: Accepted
def solve():
    N = int(raw_input())
    ret = [('a', 'a')]
    for i in range (2, N+1):
        tmp = []
        for stri in ret:
            for j in range(ord('a'), ord(stri[1]) + 1):
                tmp.append((stri[0] + chr(j), stri[1]))
            tmp.append((stri[0] + chr(ord(stri[1]) + 1), chr(ord(stri[1]) + 1)))
        ret = tmp
    for stri in ret:
        print stri[0]

if __name__ == '__main__':
    solve()
# Judge status: Accepted
n,m,x = map(int, input().split())

c = [0 for _ in range(n)]
a = [[0] for j in range(n)]

for i in range(n):
  c[i],*a[i] = map(int, input().split())

cmin = sum(c) + 1
tassei = False

for i in range(1<<n):
  rikai = [0 for i in range(m)]
  cnow = 0
  for j in range(n):
    if i & (1<<j):
      cnow+=c[j]
      for mnow in range(m):
        rikai[mnow]+=a[j][mnow]
  if min(rikai)>=x:
    tassei = True
    cmin = min(cmin, cnow)

if tassei:
  print(cmin)
else:
  print(-1)
# Judge status: Accepted
abc=sorted(list(map(int,input().split())),reverse=True)
a=[1]*10
for i in range(10**7):
    a.append(a)
print(sum(abc)+abc[0]*9)
# Judge status: Wrong Answer
n = int(input())
w = [int(i) for i in input().split()]
s = sum(w) // 2
x = 0
for i in w:
    if s - x > x + i - s:
        x += i
    else:
        break
print(abs(s - x) * 2)
# Judge status: Accepted
a, b = map(int, input().split())
if a>=13:
  print(b)
elif 6<=a<=12:
  print(b//2)
else:
  print(0)
# Judge status: Wrong Answer
s = list(input())
t = list(input())
S,T = set(s),set(t)
sl = tl = []
for i in S:
    sl.append([j for j, x in enumerate(s) if x == i])

for i in T:
    tl.append([j for j, x in enumerate(t) if x == i])

if sorted(sl)==sorted(tl):print('Yes')
else:print('No')
# Judge status: Accepted
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


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

    S = iss()
    T = iss()
    
    print('Yes' if S in T*2 else 'No')


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
import math

n = int(input())
p = [x-1 for x in list(map(int, input().split()))]

c = 0
flag = 0
ans = 0

for i in range(n):
    if p[i] == i and flag:
        c += 1
    elif p[i] == i:
        c += 1
        flag = 1
    elif p[i] != i and c > 0:
        if c == 1:
            ans += 1
        else:
            ans += math.floor(c/2)
        
        c = 0
        flag = 0

ans += math.floor(c/2)

print(ans)
# Judge status: Accepted
def is_square_num(n):
  a = 0
  for i in range(0, n+1):
    if a == n:
      return True
    if a > n:
      return False
    a += i * 2 + 1

a, b = map(str, input().split())
val = int(a+b)
if is_square_num(val):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n = int(input())
al = list(input())
cr = al.count('R')
cr2 = cr//2
ans = 0
flag = False
flag2 = False
for a in al[::-1]:
    if a == 'R':
        cr2 -= 1
    if cr2 == 0:
        flag = True
        continue

    if flag and not flag2 and a == 'R':
        flag2 = True
        continue

    if flag2 and a == 'W':
        ans += 1

print(ans)
# Judge status: Accepted
a, b, c = map(int,input().split())
print(c - (a - b) if c - (a - b) > 0 else 0)
# Judge status: Wrong Answer
A, B, T = map(int, input().split())

print(int(B/A * (T + 0.5)))
# Judge status: Accepted
P=2019
S = input()
N=len(S)
count=[0]*P
ans = 0
count[0] = 1
u = 0
for i, s in enumerate(reversed(S)):
  u = (int(s) * pow(10, i, P) + u) % P
  ans += count[u]
  count[u] += 1
 
print(ans)
# Judge status: Accepted
n = list(input())

for i in n:
    if int(i) == 7:
        print('Yes')
        break
else:
    print('No')
# Judge status: Accepted
n,k = map(int, input().split())

n_list=list(range(n+1))

saisyou=sum(n_list[0:k])
saidai=sum(n_list[n-k+1:n+1])

ans=saidai-saisyou+1

for i in range(k+1,n+2):
    saisyou+=n_list[i-1]
    saidai+=n_list[-(i)]
    ans+=saidai-saisyou+1
    ans%=10**9+7

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

Ls.sort(reverse=True)

count = 0
for k, Lk in enumerate(Ls[:-2]):
    for j, Lj in enumerate(Ls[k+1:-1]):
        for i, Li in enumerate(Ls[k+j+2:]):
            if Lk == Lj or Lj == Li or Li == Lk:
                continue
            if Lk < Lj + Li:
                count += 1

print(count)
# Judge status: Accepted
n, k = map(int, input().split())

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

lst.sort()
print(sum(lst[:k]))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

for i in range(len(A)):
    if A[i]%2 == 0:
        if A[i]%3 != 0 and  A[i]%5 != 0:
            print("DENIED")
            exit(0)

print("APPROVED")
# Judge status: Accepted
n = int(input())
a = [int(x) for x in input().split()]
ans = pow(10, 15)
key = sum(a)
p = 0
for i in range(n-1):
  p += a[i]
  if ans > abs(key-2*p):
    ans = abs(key-2*p)
    
print(ans)
# Judge status: Wrong Answer
a,b,t = map(int,input().split())
bis = 0
for i in range(1,20):
    time = a * i
    if time < t + 0.5:
        bis += b
print(bis)
# Judge status: Accepted
N = int(input())
x = N * 800
y = (N // 15) * 200

answer = x - y

print(answer)
# Judge status: Accepted
import numpy as np


a, b = map(int ,input().split())
l = np.array([a, b, a+b])
l %= 3
if all(l):
    print("Impossible")
else:
    print("Possible")
# Judge status: Accepted
d, n = map(int, input().split())
 
if d == 0:
    if n != 100:
        print(n)
    else:
        print(n + 1)
elif d == 1:
    if n != 100:
        print(n * 100)
    else:
        print(n * 100 + 100)
else:
    if n != 100:
        print(n * 10000)
    else:
        print(n * 10000 + 10000)
# Judge status: Accepted
import math


def main():
    n = int(input())
    # n, m = map(int, input().split())
    # a = list(map(int, input().split()))
    # s = input()
    # h = [int(input()) for _ in rane(n)]

    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())
    print(math.ceil(n / min(a, b, c, d, e)) + 4)


if __name__ == '__main__':
    main()