N, M = map(int, input().split())
coins = list(map(int, input().split()))

dp = [[N for _ in range(N+1)] for _ in range(M+1)]
dp[0][0] = 0

for i in range(M):
    c = coins[i]
    for j in range(N+1):
        if j-c >= 0:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j-c]+1)
        else:
            dp[i+1][j] = dp[i][j]

print(dp[M][N])
 N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M coins = list(map(int, input().split())) coins list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split [N for _ in range(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) [N for _ in range(N+1)] dp = [[N for _ in range(N+1)] for _ in range(M+1)] dp [[N for _ in range(N+1)] for _ in range(M+1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(M):
    c = coins[i]
    for j in range(N+1):
        if j-c >= 0:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j-c]+1)
        else:
            dp[i+1][j] = dp[i][j] i range(M) range M c = coins[i] c coins[i] coins i for j in range(N+1):
        if j-c >= 0:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j-c]+1)
        else:
            dp[i+1][j] = dp[i][j] j range(N+1) range N+1 N 1 if j-c >= 0:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j-c]+1)
        else:
            dp[i+1][j] = dp[i][j] j-c >= 0 j-c j c 0 dp[i+1][j] = min(dp[i][j], dp[i+1][j-c]+1) dp[i+1][j] [i+1] dp i+1 i 1 j min(dp[i][j], dp[i+1][j-c]+1) min dp[i][j] [i] dp i j dp[i+1][j-c]+1 dp[i+1][j-c] [i+1] dp i+1 i 1 j-c j c 1 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 print(dp[M][N]) print dp[M][N] [M] dp M N N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M coins = list(map(int, input().split())) list(map(int, input().split())) coins c = coins[i] coins[i] c dp = [[N for _ in range(N+1)] for _ in range(M+1)] [[N for _ in range(N+1)] for _ in range(M+1)] dp
N, M = map(int, input().split())
coins = list(map(int, input().split()))

dp = [[N for _ in range(N+1)] for _ in range(M+1)]
dp[0][0] = 0

for i in range(M):
    c = coins[i]
    for j in range(N+1):
        if j-c >= 0:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j-c]+1)
        else:
            dp[i+1][j] = dp[i][j]

print(dp[M][N])

