import sys
sys.setrecursionlimit(10000)
dp = []
coins = []
INF = 9999999

def change(n, m):
    if n == 0:
        return 0
    if dp[n] == INF:
        res = INF
        for j in range(0, m):
            if n - coins[j] >= 0:
                res = min(res, change(n - coins[j], m) + 1)
        dp[n] = res
    return dp[n]

line = input()
n, m = list(map(int, line.split()))
line = input()
d = list(map(int, line.split()))
coins = sorted(d)
coins.reverse()
dp = [INF] * (n + 1)
change(n, m)
print(dp[n]) import sys sys sys.setrecursionlimit(10000) sys.setrecursionlimit sys setrecursionlimit 10000 dp = [] dp [] coins = [] coins [] INF = 9999999 INF 9999999 def change(n, m):
    if n == 0:
        return 0
    if dp[n] == INF:
        res = INF
        for j in range(0, m):
            if n - coins[j] >= 0:
                res = min(res, change(n - coins[j], m) + 1)
        dp[n] = res
    return dp[n] change if n == 0:
        return 0
     n == 0 n 0 return 0 0 if dp[n] == INF:
        res = INF
        for j in range(0, m):
            if n - coins[j] >= 0:
                res = min(res, change(n - coins[j], m) + 1)
        dp[n] = res
     dp[n] == INF dp[n] dp n INF res = INF res INF for j in range(0, m):
            if n - coins[j] >= 0:
                res = min(res, change(n - coins[j], m) + 1)
         j range(0, m) range 0 m if n - coins[j] >= 0:
                res = min(res, change(n - coins[j], m) + 1)
         n - coins[j] >= 0 n - coins[j] n coins[j] coins j 0 res = min(res, change(n - coins[j], m) + 1) res min(res, change(n - coins[j], m) + 1) min res change(n - coins[j], m) + 1 change(n - coins[j], m) change n - coins[j] n coins[j] coins j m 1 dp[n] = res dp[n] dp n res return dp[n] dp[n] dp n n n m m line = input() line input() input n, m = list(map(int, line.split())) n list(map(int, line.split())) list map(int, line.split()) map int line.split() line.split line split m line = input() line input() input d = list(map(int, line.split())) d list(map(int, line.split())) list map(int, line.split()) map int line.split() line.split line split coins = sorted(d) coins sorted(d) sorted d coins.reverse() coins.reverse coins reverse dp = [INF] * (n + 1) dp [INF] * (n + 1) [INF] INF n + 1 n 1 change(n, m) change n m print(dp[n]) print dp[n] dp n dp = [] [] dp line = input() input() line d = list(map(int, line.split())) list(map(int, line.split())) d INF = 9999999 9999999 INF dp = [INF] * (n + 1) [INF] * (n + 1) dp n, m = list(map(int, line.split())) list(map(int, line.split())) n m = list(map(int, line.split())) list(map(int, line.split())) m line = input() input() line coins = [] [] coins coins = sorted(d) sorted(d) coins def change(n, m):
    if n == 0:
        return 0
    if dp[n] == INF:
        res = INF
        for j in range(0, m):
            if n - coins[j] >= 0:
                res = min(res, change(n - coins[j], m) + 1)
        dp[n] = res
    return dp[n] def change(n, m):
    if n == 0:
        return 0
    if dp[n] == INF:
        res = INF
        for j in range(0, m):
            if n - coins[j] >= 0:
                res = min(res, change(n - coins[j], m) + 1)
        dp[n] = res
    return dp[n] change
import sys
sys.setrecursionlimit(10000)
dp = []
coins = []
INF = 9999999

def change(n, m):
    if n == 0:
        return 0
    if dp[n] == INF:
        res = INF
        for j in range(0, m):
            if n - coins[j] >= 0:
                res = min(res, change(n - coins[j], m) + 1)
        dp[n] = res
    return dp[n]

line = input()
n, m = list(map(int, line.split()))
line = input()
d = list(map(int, line.split()))
coins = sorted(d)
coins.reverse()
dp = [INF] * (n + 1)
change(n, m)
print(dp[n])
