n, m = map(int, input().split())
c = list(map(int, input().split()))
INF = float('inf')
dp =[0] + [INF for _ in range(n)]

#print(c)

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)
        pass
    #print(dp, c[i])
print(dp[n])
 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 = float('inf') INF float('inf') float 'inf' INF for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) INF dp =[0] + [INF for _ in range(n)] dp [0] + [INF for _ in range(n)] [0] 0 [INF for _ in range(n)] 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)
        pass
    #print(dp, c[i]) 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)
        pass
    #print(dp, c[i]) 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 =[0] + [INF for _ in range(n)] [0] + [INF for _ in range(n)] dp INF = float('inf') float('inf') INF m = map(int, input().split()) map(int, input().split()) m c = list(map(int, input().split())) list(map(int, input().split())) c n, m = map(int, input().split()) map(int, input().split()) n
n, m = map(int, input().split())
c = list(map(int, input().split()))
INF = float('inf')
dp =[0] + [INF for _ in range(n)]

#print(c)

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)
        pass
    #print(dp, c[i])
print(dp[n])

