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

# Coin Changing Problem
T = [0] + [float('inf')] * n

for c in C:
    for j in range(c, n+1):
        T[j] = min(T[j], T[j - c] + 1)

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

# Coin Changing Problem
T = [0] + [float('inf')] * n

for c in C:
    for j in range(c, n+1):
        T[j] = min(T[j], T[j - c] + 1)

print(T[-1])