n, m = map(int, input().split())
c = list(map(int, input().split()))

dp = [0] + [50000]*n

for i in range(m):
    for j in range(c[i], n+1):
        dp[j] = min(dp[j], dp[j-c[i]] + 1)

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 dp = [0] + [50000]*n dp [0] + [50000]*n [0] 0 [50000]*n [50000] 50000 n for i in range(m):
    for j in range(c[i], n+1):
        dp[j] = min(dp[j], dp[j-c[i]] + 1) i range(m) range m for j in range(c[i], n+1):
        dp[j] = min(dp[j], dp[j-c[i]] + 1) j range(c[i], n+1) range c[i] c i n+1 n 1 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 m = map(int, input().split()) map(int, input().split()) m n, m = map(int, input().split()) map(int, input().split()) n dp = [0] + [50000]*n [0] + [50000]*n dp c = list(map(int, input().split())) list(map(int, input().split())) c
n, m = map(int, input().split())
c = list(map(int, input().split()))

dp = [0] + [50000]*n

for i in range(m):
    for j in range(c[i], n+1):
        dp[j] = min(dp[j], dp[j-c[i]] + 1)

print(dp[n])