
import sys

inf_val = 10**10

m, n = map(int, sys.stdin.readline().split())
numbers = map(int, sys.stdin.readline().split())

dp = [inf_val]*(m+1)
dp[0] = 0

for x in numbers:
    for y in xrange(x, m+1):
        dp[y] =  min(dp[y-x]+1, dp[y])

print dp[m] import sys sys inf_val = 10**10 inf_val 10**10 10 10 m, n = map(int, sys.stdin.readline().split()) m 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 n numbers = map(int, sys.stdin.readline().split()) numbers 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 = [inf_val]*(m+1) dp [inf_val]*(m+1) [inf_val] inf_val m+1 m 1 dp[0] = 0 dp[0] dp 0 0 for x in numbers:
    for y in xrange(x, m+1):
        dp[y] =  min(dp[y-x]+1, dp[y]) x numbers for y in xrange(x, m+1):
        dp[y] =  min(dp[y-x]+1, dp[y]) y xrange(x, m+1) xrange x m+1 m 1 dp[y] =  min(dp[y-x]+1, dp[y]) dp[y] dp y min(dp[y-x]+1, dp[y]) min dp[y-x]+1 dp[y-x] dp y-x y x 1 dp[y] dp y print dp[m] dp m m, n = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) m numbers = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) numbers inf_val = 10**10 10**10 inf_val dp = [inf_val]*(m+1) [inf_val]*(m+1) dp n = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) n

import sys

inf_val = 10**10

m, n = map(int, sys.stdin.readline().split())
numbers = map(int, sys.stdin.readline().split())

dp = [inf_val]*(m+1)
dp[0] = 0

for x in numbers:
    for y in xrange(x, m+1):
        dp[y] =  min(dp[y-x]+1, dp[y])

print dp[m]