n, m = [int(el) for el in input().split(' ')]
c = [int(el) for el in input().split(' ')]

t = [0] + [float('inf') for _ in range(n)]

for i in range(m):
    for j in range(c[i], n+1):
        t[j] = min(t[j], t[j-c[i]] + 1)
print(t[n]) int(el) for el in input().split(' ') for el in input().split(' ') el input().split(' ') ().split () input split ' ' for el in input().split(' ') int(el) int el n, m = [int(el) for el in input().split(' ')] n [int(el) for el in input().split(' ')] m int(el) for el in input().split(' ') for el in input().split(' ') el input().split(' ') ().split () input split ' ' for el in input().split(' ') int(el) int el c = [int(el) for el in input().split(' ')] c [int(el) for el in input().split(' ')] float('inf') for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) float('inf') float 'inf' t = [0] + [float('inf') for _ in range(n)] t [0] + [float('inf') for _ in range(n)] [0] 0 [float('inf') for _ in range(n)] for i in range(m):
    for j in range(c[i], n+1):
        t[j] = min(t[j], t[j-c[i]] + 1) i range(m) range m for j in range(c[i], n+1):
        t[j] = min(t[j], t[j-c[i]] + 1) j range(c[i], n+1) range c[i] c i n+1 n 1 t[j] = min(t[j], t[j-c[i]] + 1) t[j] t j min(t[j], t[j-c[i]] + 1) min t[j] t j t[j-c[i]] + 1 t[j-c[i]] t j-c[i] j c[i] c i 1 print(t[n]) print t[n] t n m = [int(el) for el in input().split(' ')] [int(el) for el in input().split(' ')] m t = [0] + [float('inf') for _ in range(n)] [0] + [float('inf') for _ in range(n)] t c = [int(el) for el in input().split(' ')] [int(el) for el in input().split(' ')] c n, m = [int(el) for el in input().split(' ')] [int(el) for el in input().split(' ')] n
n, m = [int(el) for el in input().split(' ')]
c = [int(el) for el in input().split(' ')]

t = [0] + [float('inf') for _ in range(n)]

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