import sys
sys.setrecursionlimit(15000)
n,m = map(int,sys.stdin.readline().split())
M = list(map(int,sys.stdin.readline().split()))
dp = [float("inf")]*(n+1)
dp[0] = 0
for e in M:
  for i in range(n+1):
    if 0 <= i-e and i-e < n:
      dp[i] = min(dp[i],dp[i-e]+1)
print(dp[-1]) import sys sys sys.setrecursionlimit(15000) sys.setrecursionlimit sys setrecursionlimit 15000 n,m = map(int,sys.stdin.readline().split()) n map(int,sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split m M = list(map(int,sys.stdin.readline().split())) M list(map(int,sys.stdin.readline().split())) list map(int,sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split dp = [float("inf")]*(n+1) dp [float("inf")]*(n+1) [float("inf")] float("inf") float "inf" n+1 n 1 dp[0] = 0 dp[0] dp 0 0 for e in M:
  for i in range(n+1):
    if 0 <= i-e and i-e < n:
      dp[i] = min(dp[i],dp[i-e]+1) e M for i in range(n+1):
    if 0 <= i-e and i-e < n:
      dp[i] = min(dp[i],dp[i-e]+1) i range(n+1) range n+1 n 1 if 0 <= i-e and i-e < n:
      dp[i] = min(dp[i],dp[i-e]+1) 0 <= i-e and i-e < n 0 <= i-e 0 i-e i e i-e < n i-e i e n dp[i] = min(dp[i],dp[i-e]+1) dp[i] dp i min(dp[i],dp[i-e]+1) min dp[i] dp i dp[i-e]+1 dp[i-e] dp i-e i e 1 print(dp[-1]) print dp[-1] dp -1 dp = [float("inf")]*(n+1) [float("inf")]*(n+1) dp n,m = map(int,sys.stdin.readline().split()) map(int,sys.stdin.readline().split()) n m = map(int,sys.stdin.readline().split()) map(int,sys.stdin.readline().split()) m M = list(map(int,sys.stdin.readline().split())) list(map(int,sys.stdin.readline().split())) M
import sys
sys.setrecursionlimit(15000)
n,m = map(int,sys.stdin.readline().split())
M = list(map(int,sys.stdin.readline().split()))
dp = [float("inf")]*(n+1)
dp[0] = 0
for e in M:
  for i in range(n+1):
    if 0 <= i-e and i-e < n:
      dp[i] = min(dp[i],dp[i-e]+1)
print(dp[-1])
