# import numpy as np

N, M = list(map(int, input().split()))
C = list(map(int, input().split()))
T = [float('inf')] * (N+1)
T[0] = 0

for i in range(M):
    for j in range(C[i], N + 1):
        T[j] = min(T[j], T[j - C[i]] + 1)

print(T[-1]) N, M = list(map(int, input().split())) N list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split M C = list(map(int, input().split())) C list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split T = [float('inf')] * (N+1) T [float('inf')] * (N+1) [float('inf')] float('inf') float 'inf' N+1 N 1 T[0] = 0 T[0] T 0 0 for i in range(M):
    for j in range(C[i], N + 1):
        T[j] = min(T[j], T[j - C[i]] + 1) i range(M) range M for j in range(C[i], N + 1):
        T[j] = min(T[j], T[j - C[i]] + 1) j range(C[i], N + 1) range C[i] C i N + 1 N 1 T[j] = min(T[j], T[j - C[i]] + 1) T[j] T j min(T[j], T[j - C[i]] + 1) min T[j] T j T[j - C[i]] + 1 T[j - C[i]] T j - C[i] j C[i] C i 1 print(T[-1]) print T[-1] T -1 M = list(map(int, input().split())) list(map(int, input().split())) M N, M = list(map(int, input().split())) list(map(int, input().split())) N T = [float('inf')] * (N+1) [float('inf')] * (N+1) T C = list(map(int, input().split())) list(map(int, input().split())) C
# import numpy as np

N, M = list(map(int, input().split()))
C = list(map(int, input().split()))
T = [float('inf')] * (N+1)
T[0] = 0

for i in range(M):
    for j in range(C[i], N + 1):
        T[j] = min(T[j], T[j - C[i]] + 1)

print(T[-1])
