n, m = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] + [float('inf')]*(n)
for i in range(m):
    for j in range(a[i],n+1):
        dp[j] = min(dp[j],dp[j-a[i]]+1)
        
print(dp[-1]) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m a = list(map(int, input().split())) a list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split dp = [0] + [float('inf')]*(n) dp [0] + [float('inf')]*(n) [0] 0 [float('inf')]*(n) [float('inf')] float('inf') float 'inf' n for i in range(m):
    for j in range(a[i],n+1):
        dp[j] = min(dp[j],dp[j-a[i]]+1)
         i range(m) range m for j in range(a[i],n+1):
        dp[j] = min(dp[j],dp[j-a[i]]+1)
         j range(a[i],n+1) range a[i] a i n+1 n 1 dp[j] = min(dp[j],dp[j-a[i]]+1) dp[j] dp j min(dp[j],dp[j-a[i]]+1) min dp[j] dp j dp[j-a[i]]+1 dp[j-a[i]] dp j-a[i] j a[i] a i 1 print(dp[-1]) print dp[-1] dp -1 n, m = map(int, input().split()) map(int, input().split()) n a = list(map(int, input().split())) list(map(int, input().split())) a dp = [0] + [float('inf')]*(n) [0] + [float('inf')]*(n) dp m = map(int, input().split()) map(int, input().split()) m
n, m = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] + [float('inf')]*(n)
for i in range(m):
    for j in range(a[i],n+1):
        dp[j] = min(dp[j],dp[j-a[i]]+1)
        
print(dp[-1])
