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