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

inf = 10 ** 6

dp = [inf] * (n + 1)
dp[0] = 0

for c in range(m):
  for v in range(n + 1):
    if v >= coins[c]:
      dp[v] = min(dp[v - coins[c]] + 1,dp[v])
    else:
      dp[v] = dp[v]
      
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 inf = 10 ** 6 inf 10 ** 6 10 6 dp = [inf] * (n + 1) dp [inf] * (n + 1) [inf] inf n + 1 n 1 dp[0] = 0 dp[0] dp 0 0 for c in range(m):
  for v in range(n + 1):
    if v >= coins[c]:
      dp[v] = min(dp[v - coins[c]] + 1,dp[v])
    else:
      dp[v] = dp[v]
       c range(m) range m for v in range(n + 1):
    if v >= coins[c]:
      dp[v] = min(dp[v - coins[c]] + 1,dp[v])
    else:
      dp[v] = dp[v]
       v range(n + 1) range n + 1 n 1 if v >= coins[c]:
      dp[v] = min(dp[v - coins[c]] + 1,dp[v])
    else:
      dp[v] = dp[v]
       v >= coins[c] v coins[c] coins c dp[v] = min(dp[v - coins[c]] + 1,dp[v]) dp[v] dp v min(dp[v - coins[c]] + 1,dp[v]) min dp[v - coins[c]] + 1 dp[v - coins[c]] dp v - coins[c] v coins[c] coins c 1 dp[v] dp v dp[v] = dp[v] dp[v] dp v dp[v] dp v print(dp[n]) print dp[n] dp n m = map(int,input().split()) map(int,input().split()) m dp = [inf] * (n + 1) [inf] * (n + 1) dp coins = list(map(int,input().split())) list(map(int,input().split())) coins inf = 10 ** 6 10 ** 6 inf n,m = map(int,input().split()) map(int,input().split()) n
n,m = map(int,input().split())
coins = list(map(int,input().split()))

inf = 10 ** 6

dp = [inf] * (n + 1)
dp[0] = 0

for c in range(m):
  for v in range(n + 1):
    if v >= coins[c]:
      dp[v] = min(dp[v - coins[c]] + 1,dp[v])
    else:
      dp[v] = dp[v]
      
print(dp[n])
