n, m = map(int, input().split())
*C, = map(int, input().split())
# n, m = 15, 6
# C = [1, 2, 7, 8, 12, 50]
# DP[i][j]=i種類以内でj円払う最小枚数
inf = 10**10
DP = [[inf for j in range(n+1)] for i in range(m+1)]
DP[0][0] = 0
for i in range(m):
    for j in range(n+1):
        if j < C[i]:
            DP[i+1][j] = DP[i][j]
        else:
            DP[i+1][j] = min(DP[i][j], DP[i+1][j-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 *C, = map(int, input().split()) *C C map(int, input().split()) map int input().split() ().split () input split inf = 10**10 inf 10**10 10 10 [inf for j in range(n+1)] for i in range(m+1) for i in range(m+1) i range(m+1) range m+1 m 1 for i in range(m+1) [inf for j in range(n+1)] DP = [[inf for j in range(n+1)] for i in range(m+1)] DP [[inf for j in range(n+1)] for i in range(m+1)] DP[0][0] = 0 DP[0][0] [0] DP 0 0 0 for i in range(m):
    for j in range(n+1):
        if j < C[i]:
            DP[i+1][j] = DP[i][j]
        else:
            DP[i+1][j] = min(DP[i][j], DP[i+1][j-C[i]]+1) i range(m) range m for j in range(n+1):
        if j < C[i]:
            DP[i+1][j] = DP[i][j]
        else:
            DP[i+1][j] = min(DP[i][j], DP[i+1][j-C[i]]+1) j range(n+1) range n+1 n 1 if j < C[i]:
            DP[i+1][j] = DP[i][j]
        else:
            DP[i+1][j] = min(DP[i][j], DP[i+1][j-C[i]]+1) j < C[i] j C[i] C i DP[i+1][j] = DP[i][j] DP[i+1][j] [i+1] DP i+1 i 1 j DP[i][j] [i] DP i j DP[i+1][j] = min(DP[i][j], DP[i+1][j-C[i]]+1) DP[i+1][j] [i+1] DP i+1 i 1 j min(DP[i][j], DP[i+1][j-C[i]]+1) min DP[i][j] [i] DP i j DP[i+1][j-C[i]]+1 DP[i+1][j-C[i]] [i+1] DP i+1 i 1 j-C[i] j C[i] C i 1 print(DP[m][n]) print DP[m][n] [m] DP m n m = map(int, input().split()) map(int, input().split()) m inf = 10**10 10**10 inf n, m = map(int, input().split()) map(int, input().split()) n DP = [[inf for j in range(n+1)] for i in range(m+1)] [[inf for j in range(n+1)] for i in range(m+1)] DP
n, m = map(int, input().split())
*C, = map(int, input().split())
# n, m = 15, 6
# C = [1, 2, 7, 8, 12, 50]
# DP[i][j]=i種類以内でj円払う最小枚数
inf = 10**10
DP = [[inf for j in range(n+1)] for i in range(m+1)]
DP[0][0] = 0
for i in range(m):
    for j in range(n+1):
        if j < C[i]:
            DP[i+1][j] = DP[i][j]
        else:
            DP[i+1][j] = min(DP[i][j], DP[i+1][j-C[i]]+1)
print(DP[m][n])

