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

c = list(map(int, input().split()))
c.sort()

inf = float("inf")
dp = [inf for _ in range(n+1)] #最小化問題の時はinfのほうが良いのかな
dp[0] = 0

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


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 c.sort() c.sort c sort inf = float("inf") inf float("inf") float "inf" 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 i in range(1, n+1):
    for j in range(m):
        if i >= c[j]:
            dp[i] = min(dp[i-c[j]]+1, dp[i])
        else:
            dp[i] = dp[i] i range(1, n+1) range 1 n+1 n 1 for j in range(m):
        if i >= c[j]:
            dp[i] = min(dp[i-c[j]]+1, dp[i])
        else:
            dp[i] = dp[i] j range(m) range m if i >= c[j]:
            dp[i] = min(dp[i-c[j]]+1, dp[i])
        else:
            dp[i] = dp[i] i >= c[j] i c[j] c j dp[i] = min(dp[i-c[j]]+1, dp[i]) dp[i] dp i min(dp[i-c[j]]+1, dp[i]) min dp[i-c[j]]+1 dp[i-c[j]] dp i-c[j] i c[j] c j 1 dp[i] dp i dp[i] = dp[i] dp[i] dp i dp[i] dp i print(dp[n]) print dp[n] dp n inf = float("inf") float("inf") 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 = list(map(int, input().split())) list(map(int, input().split())) c
n, m = map(int, input().split())

c = list(map(int, input().split()))
c.sort()

inf = float("inf")
dp = [inf for _ in range(n+1)] #最小化問題の時はinfのほうが良いのかな
dp[0] = 0

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


print(dp[n])
