INF = 10**18

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

dp = [INF for _ in range(N+1)]
dp[0] = 0

for i in range(M):
    for j in range(N+1):
        if j-C[i] >= 0:
            dp[j] = min(dp[j],dp[j-C[i]]+1)

print(dp[N]) INF = 10**18 INF 10**18 10 18 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 INF for _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) INF dp = [INF for _ in range(N+1)] dp [INF for _ in range(N+1)] dp[0] = 0 dp[0] dp 0 0 for i in range(M):
    for j in range(N+1):
        if j-C[i] >= 0:
            dp[j] = min(dp[j],dp[j-C[i]]+1) i range(M) range M for j in range(N+1):
        if j-C[i] >= 0:
            dp[j] = min(dp[j],dp[j-C[i]]+1) j range(N+1) range N+1 N 1 if j-C[i] >= 0:
            dp[j] = min(dp[j],dp[j-C[i]]+1) j-C[i] >= 0 j-C[i] j C[i] C i 0 dp[j] = min(dp[j],dp[j-C[i]]+1) dp[j] dp j min(dp[j],dp[j-C[i]]+1) min dp[j] dp j dp[j-C[i]]+1 dp[j-C[i]] dp j-C[i] j C[i] C i 1 print(dp[N]) print dp[N] dp N dp = [INF for _ in range(N+1)] [INF for _ in range(N+1)] dp N,M = map(int,input().split()) map(int,input().split()) N M = map(int,input().split()) map(int,input().split()) M C = list(map(int,input().split())) list(map(int,input().split())) C INF = 10**18 10**18 INF
INF = 10**18

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

dp = [INF for _ in range(N+1)]
dp[0] = 0

for i in range(M):
    for j in range(N+1):
        if j-C[i] >= 0:
            dp[j] = min(dp[j],dp[j-C[i]]+1)

print(dp[N])
