n, m = map(int, input().split())
coin = sorted(list(map(int, input().split())))
T = [0]+[float('inf')]*n
for i in range(m):
    for j in range(coin[i], n+1):
        T[j] = min(T[j], T[j-coin[i]]+1)
print(T[-1]) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m coin = sorted(list(map(int, input().split()))) coin sorted(list(map(int, input().split()))) sorted list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split T = [0]+[float('inf')]*n T [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(coin[i], n+1):
        T[j] = min(T[j], T[j-coin[i]]+1) i range(m) range m for j in range(coin[i], n+1):
        T[j] = min(T[j], T[j-coin[i]]+1) j range(coin[i], n+1) range coin[i] coin i n+1 n 1 T[j] = min(T[j], T[j-coin[i]]+1) T[j] T j min(T[j], T[j-coin[i]]+1) min T[j] T j T[j-coin[i]]+1 T[j-coin[i]] T j-coin[i] j coin[i] coin i 1 print(T[-1]) print T[-1] T -1 T = [0]+[float('inf')]*n [0]+[float('inf')]*n T n, m = map(int, input().split()) map(int, input().split()) n coin = sorted(list(map(int, input().split()))) sorted(list(map(int, input().split()))) coin m = map(int, input().split()) map(int, input().split()) m
n, m = map(int, input().split())
coin = sorted(list(map(int, input().split())))
T = [0]+[float('inf')]*n
for i in range(m):
    for j in range(coin[i], n+1):
        T[j] = min(T[j], T[j-coin[i]]+1)
print(T[-1])