charge, n_coin = map(int,input().split())
coin_ls = list(map(int, input().split()))
coin_ls = [0] + coin_ls

dp = [[float('inf')] * (charge+1) for _ in range(n_coin+1)]
dp[0][0] = 0
for coin_i in range(1,n_coin+1):
    for now_charge in range(0,charge+1):
        if now_charge - coin_ls[coin_i] >= 0:
            dp[coin_i][now_charge] = min(dp[coin_i][now_charge], dp[coin_i][now_charge-coin_ls[coin_i]]+1)
        dp[coin_i][now_charge] = min(dp[coin_i-1][now_charge], dp[coin_i][now_charge]) 
print(dp[n_coin][charge]) charge, n_coin = map(int,input().split()) charge map(int,input().split()) map int input().split() ().split () input split n_coin coin_ls = list(map(int, input().split())) coin_ls list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split coin_ls = [0] + coin_ls coin_ls [0] + coin_ls [0] 0 coin_ls [float('inf')] * (charge+1) for _ in range(n_coin+1) for _ in range(n_coin+1) _ range(n_coin+1) range n_coin+1 n_coin 1 for _ in range(n_coin+1) [float('inf')] * (charge+1) [float('inf')] float('inf') float 'inf' charge+1 charge 1 dp = [[float('inf')] * (charge+1) for _ in range(n_coin+1)] dp [[float('inf')] * (charge+1) for _ in range(n_coin+1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for coin_i in range(1,n_coin+1):
    for now_charge in range(0,charge+1):
        if now_charge - coin_ls[coin_i] >= 0:
            dp[coin_i][now_charge] = min(dp[coin_i][now_charge], dp[coin_i][now_charge-coin_ls[coin_i]]+1)
        dp[coin_i][now_charge] = min(dp[coin_i-1][now_charge], dp[coin_i][now_charge])  coin_i range(1,n_coin+1) range 1 n_coin+1 n_coin 1 for now_charge in range(0,charge+1):
        if now_charge - coin_ls[coin_i] >= 0:
            dp[coin_i][now_charge] = min(dp[coin_i][now_charge], dp[coin_i][now_charge-coin_ls[coin_i]]+1)
        dp[coin_i][now_charge] = min(dp[coin_i-1][now_charge], dp[coin_i][now_charge])  now_charge range(0,charge+1) range 0 charge+1 charge 1 if now_charge - coin_ls[coin_i] >= 0:
            dp[coin_i][now_charge] = min(dp[coin_i][now_charge], dp[coin_i][now_charge-coin_ls[coin_i]]+1)
         now_charge - coin_ls[coin_i] >= 0 now_charge - coin_ls[coin_i] now_charge coin_ls[coin_i] coin_ls coin_i 0 dp[coin_i][now_charge] = min(dp[coin_i][now_charge], dp[coin_i][now_charge-coin_ls[coin_i]]+1) dp[coin_i][now_charge] [coin_i] dp coin_i now_charge min(dp[coin_i][now_charge], dp[coin_i][now_charge-coin_ls[coin_i]]+1) min dp[coin_i][now_charge] [coin_i] dp coin_i now_charge dp[coin_i][now_charge-coin_ls[coin_i]]+1 dp[coin_i][now_charge-coin_ls[coin_i]] [coin_i] dp coin_i now_charge-coin_ls[coin_i] now_charge coin_ls[coin_i] coin_ls coin_i 1 dp[coin_i][now_charge] = min(dp[coin_i-1][now_charge], dp[coin_i][now_charge]) dp[coin_i][now_charge] [coin_i] dp coin_i now_charge min(dp[coin_i-1][now_charge], dp[coin_i][now_charge]) min dp[coin_i-1][now_charge] [coin_i-1] dp coin_i-1 coin_i 1 now_charge dp[coin_i][now_charge] [coin_i] dp coin_i now_charge print(dp[n_coin][charge]) print dp[n_coin][charge] [n_coin] dp n_coin charge coin_ls = [0] + coin_ls [0] + coin_ls coin_ls charge, n_coin = map(int,input().split()) map(int,input().split()) charge coin_ls = list(map(int, input().split())) list(map(int, input().split())) coin_ls n_coin = map(int,input().split()) map(int,input().split()) n_coin dp = [[float('inf')] * (charge+1) for _ in range(n_coin+1)] [[float('inf')] * (charge+1) for _ in range(n_coin+1)] dp
charge, n_coin = map(int,input().split())
coin_ls = list(map(int, input().split()))
coin_ls = [0] + coin_ls

dp = [[float('inf')] * (charge+1) for _ in range(n_coin+1)]
dp[0][0] = 0
for coin_i in range(1,n_coin+1):
    for now_charge in range(0,charge+1):
        if now_charge - coin_ls[coin_i] >= 0:
            dp[coin_i][now_charge] = min(dp[coin_i][now_charge], dp[coin_i][now_charge-coin_ls[coin_i]]+1)
        dp[coin_i][now_charge] = min(dp[coin_i-1][now_charge], dp[coin_i][now_charge]) 
print(dp[n_coin][charge])
