N,M = map(int, input().split())
C = list(map(int, input().split()))

C.sort()
DP = [i for i in range(N+1)]

for m in range(1,M):
    coin = C[m]
    for total in range(1, N+1):
        if total - coin >= 0:
            DP[total] = min(DP[total], DP[total - coin] + 1)

print(DP[-1]) N,M = map(int, input().split()) N 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 C.sort() C.sort C sort i for i in range(N+1) for i in range(N+1) i range(N+1) range N+1 N 1 for i in range(N+1) i DP = [i for i in range(N+1)] DP [i for i in range(N+1)] for m in range(1,M):
    coin = C[m]
    for total in range(1, N+1):
        if total - coin >= 0:
            DP[total] = min(DP[total], DP[total - coin] + 1) m range(1,M) range 1 M coin = C[m] coin C[m] C m for total in range(1, N+1):
        if total - coin >= 0:
            DP[total] = min(DP[total], DP[total - coin] + 1) total range(1, N+1) range 1 N+1 N 1 if total - coin >= 0:
            DP[total] = min(DP[total], DP[total - coin] + 1) total - coin >= 0 total - coin total coin 0 DP[total] = min(DP[total], DP[total - coin] + 1) DP[total] DP total min(DP[total], DP[total - coin] + 1) min DP[total] DP total DP[total - coin] + 1 DP[total - coin] DP total - coin total coin 1 print(DP[-1]) print DP[-1] DP -1 C = list(map(int, input().split())) list(map(int, input().split())) C N,M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M coin = C[m] C[m] coin DP = [i for i in range(N+1)] [i for i in range(N+1)] DP
N,M = map(int, input().split())
C = list(map(int, input().split()))

C.sort()
DP = [i for i in range(N+1)]

for m in range(1,M):
    coin = C[m]
    for total in range(1, N+1):
        if total - coin >= 0:
            DP[total] = min(DP[total], DP[total - coin] + 1)

print(DP[-1])
