n,m  = map(int,input().split())

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

dp = [20**10]*(n+1)
dp[0] = 0
for coin in coins:
    for price in range(coin,n+1):
        dp[price]  = min(dp[price],dp[price-coin]+1)
        
print(dp[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 dp = [20**10]*(n+1) dp [20**10]*(n+1) [20**10] 20**10 20 10 n+1 n 1 dp[0] = 0 dp[0] dp 0 0 for coin in coins:
    for price in range(coin,n+1):
        dp[price]  = min(dp[price],dp[price-coin]+1)
         coin coins for price in range(coin,n+1):
        dp[price]  = min(dp[price],dp[price-coin]+1)
         price range(coin,n+1) range coin n+1 n 1 dp[price]  = min(dp[price],dp[price-coin]+1) dp[price] dp price min(dp[price],dp[price-coin]+1) min dp[price] dp price dp[price-coin]+1 dp[price-coin] dp price-coin price coin 1 print(dp[n]) print dp[n] dp 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 dp = [20**10]*(n+1) [20**10]*(n+1) dp
n,m  = map(int,input().split())

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

dp = [20**10]*(n+1)
dp[0] = 0
for coin in coins:
    for price in range(coin,n+1):
        dp[price]  = min(dp[price],dp[price-coin]+1)
        
print(dp[n])
