n, m = map(int, input().split())
c_list = list(map(int, input().split()))
c_list.sort()
dp_list = [0] + [10**9]*(n)
for i in range(1, n+1):
    for c in c_list:
        if i - c >= 0:
            dp_list[i] = min(dp_list[i], dp_list[i-c]+1)
        else:
            break
print(dp_list[-1])
 n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m c_list = list(map(int, input().split())) c_list list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split c_list.sort() c_list.sort c_list sort dp_list = [0] + [10**9]*(n) dp_list [0] + [10**9]*(n) [0] 0 [10**9]*(n) [10**9] 10**9 10 9 n for i in range(1, n+1):
    for c in c_list:
        if i - c >= 0:
            dp_list[i] = min(dp_list[i], dp_list[i-c]+1)
        else:
            break i range(1, n+1) range 1 n+1 n 1 for c in c_list:
        if i - c >= 0:
            dp_list[i] = min(dp_list[i], dp_list[i-c]+1)
        else:
            break c c_list if i - c >= 0:
            dp_list[i] = min(dp_list[i], dp_list[i-c]+1)
        else:
            break i - c >= 0 i - c i c 0 dp_list[i] = min(dp_list[i], dp_list[i-c]+1) dp_list[i] dp_list i min(dp_list[i], dp_list[i-c]+1) min dp_list[i] dp_list i dp_list[i-c]+1 dp_list[i-c] dp_list i-c i c 1 break print(dp_list[-1]) print dp_list[-1] dp_list -1 dp_list = [0] + [10**9]*(n) [0] + [10**9]*(n) dp_list n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m c_list = list(map(int, input().split())) list(map(int, input().split())) c_list
n, m = map(int, input().split())
c_list = list(map(int, input().split()))
c_list.sort()
dp_list = [0] + [10**9]*(n)
for i in range(1, n+1):
    for c in c_list:
        if i - c >= 0:
            dp_list[i] = min(dp_list[i], dp_list[i-c]+1)
        else:
            break
print(dp_list[-1])

