inf = 10 ** 20
n,m = map(int,input().split())
c = [int(i) for i in input().split()]
dp = [inf for _ in range(n + 1)]
dp[0] = 0
for coin in c:
    for j in range(n + 1):
        if j - coin >= 0:
            dp[j] = min(dp[j], dp[j - coin] + 1)
print(dp[n])
 inf = 10 ** 20 inf 10 ** 20 10 20 n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i c = [int(i) for i in input().split()] c [int(i) for i in input().split()] inf for _ in range(n + 1) for _ in range(n + 1) _ range(n + 1) range n + 1 n 1 for _ in range(n + 1) inf dp = [inf for _ in range(n + 1)] dp [inf for _ in range(n + 1)] dp[0] = 0 dp[0] dp 0 0 for coin in c:
    for j in range(n + 1):
        if j - coin >= 0:
            dp[j] = min(dp[j], dp[j - coin] + 1) coin c for j in range(n + 1):
        if j - coin >= 0:
            dp[j] = min(dp[j], dp[j - coin] + 1) j range(n + 1) range n + 1 n 1 if j - coin >= 0:
            dp[j] = min(dp[j], dp[j - coin] + 1) j - coin >= 0 j - coin j coin 0 dp[j] = min(dp[j], dp[j - coin] + 1) dp[j] dp j min(dp[j], dp[j - coin] + 1) min dp[j] dp j dp[j - coin] + 1 dp[j - coin] dp j - coin j coin 1 print(dp[n]) print dp[n] dp n inf = 10 ** 20 10 ** 20 inf n,m = map(int,input().split()) map(int,input().split()) n dp = [inf for _ in range(n + 1)] [inf for _ in range(n + 1)] dp m = map(int,input().split()) map(int,input().split()) m c = [int(i) for i in input().split()] [int(i) for i in input().split()] c
inf = 10 ** 20
n,m = map(int,input().split())
c = [int(i) for i in input().split()]
dp = [inf for _ in range(n + 1)]
dp[0] = 0
for coin in c:
    for j in range(n + 1):
        if j - coin >= 0:
            dp[j] = min(dp[j], dp[j - coin] + 1)
print(dp[n])

