n,m = map(int,input().split())
c = [int(i) for i in input().split()]
dp = [[float("INF")]*(n+1) for _ in range(m+1)]

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

dp[0][0] = 0
for i in range(m):
    for yen in range(n+1):
        if yen - c[i] < 0: dp[i+1][yen] = dp[i][yen]
        else: dp[i+1][yen] = min(dp[i][yen],dp[i+1][yen-c[i]]+1)
print(dp[m][n])
