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

dp = [[10**18]*(N+10) for _ in range(M+10)]
dp[0][0] = 0

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

dp = [[10**18]*(N+10) for _ in range(M+10)]
dp[0][0] = 0

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



print(dp[M][N])
