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

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

dp = [0] + [50001 for i in range(N)]

for coin in coins:
    for index in range(N-coin+1):
        dp[index+coin] = min(dp[index+coin], dp[index]+1)
print(dp[N]) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M coins = map(int, input().split()) coins map(int, input().split()) map int input().split() ().split () input split 50001 for i in range(N) for i in range(N) i range(N) range N for i in range(N) 50001 dp = [0] + [50001 for i in range(N)] dp [0] + [50001 for i in range(N)] [0] 0 [50001 for i in range(N)] for coin in coins:
    for index in range(N-coin+1):
        dp[index+coin] = min(dp[index+coin], dp[index]+1) coin coins for index in range(N-coin+1):
        dp[index+coin] = min(dp[index+coin], dp[index]+1) index range(N-coin+1) range N-coin+1 N-coin N coin 1 dp[index+coin] = min(dp[index+coin], dp[index]+1) dp[index+coin] dp index+coin index coin min(dp[index+coin], dp[index]+1) min dp[index+coin] dp index+coin index coin dp[index]+1 dp[index] dp index 1 print(dp[N]) print dp[N] dp N coins = map(int, input().split()) map(int, input().split()) coins N, M = map(int, input().split()) map(int, input().split()) N dp = [0] + [50001 for i in range(N)] [0] + [50001 for i in range(N)] dp M = map(int, input().split()) map(int, input().split()) M
N, M = map(int, input().split())

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

dp = [0] + [50001 for i in range(N)]

for coin in coins:
    for index in range(N-coin+1):
        dp[index+coin] = min(dp[index+coin], dp[index]+1)
print(dp[N])
