import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

from collections import deque
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
c = na()
dp = [[100000000] * (50001) for _ in range(20+1)]
for i in range(20+1):
    dp[i][0] = 0
for i in range(m):
    for j in range(n+1):
        if j >= c[i]:
            dp[i+1][j] = min(dp[i+1][j-c[i]] + 1, dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[m][n]) import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time math string itertools fractions heapq collections re array bisect sys random time from collections import deque sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 inf = 10**20 inf 10**20 10 20 mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 stdin = sys.stdin stdin sys.stdin sys stdin ni = lambda: int(ns()) ni lambda: int(ns()) int(ns()) int ns() ns na = lambda: list(map(int, stdin.readline().split())) na lambda: list(map(int, stdin.readline().split())) list(map(int, stdin.readline().split())) list map(int, stdin.readline().split()) map int stdin.readline().split() stdin.readline().split stdin.readline() stdin.readline stdin readline split ns = lambda: stdin.readline().rstrip() ns lambda: stdin.readline().rstrip() stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip n, m = na() n na() na m c = na() c na() na [100000000] * (50001) for _ in range(20+1) for _ in range(20+1) _ range(20+1) range 20+1 20 1 for _ in range(20+1) [100000000] * (50001) [100000000] 100000000 50001 dp = [[100000000] * (50001) for _ in range(20+1)] dp [[100000000] * (50001) for _ in range(20+1)] for i in range(20+1):
    dp[i][0] = 0 i range(20+1) range 20+1 20 1 dp[i][0] = 0 dp[i][0] [i] dp i 0 0 for i in range(m):
    for j in range(n+1):
        if j >= c[i]:
            dp[i+1][j] = min(dp[i+1][j-c[i]] + 1, dp[i][j])
        else:
            dp[i+1][j] = dp[i][j] i range(m) range m for j in range(n+1):
        if j >= c[i]:
            dp[i+1][j] = min(dp[i+1][j-c[i]] + 1, dp[i][j])
        else:
            dp[i+1][j] = dp[i][j] j range(n+1) range n+1 n 1 if j >= c[i]:
            dp[i+1][j] = min(dp[i+1][j-c[i]] + 1, dp[i][j])
        else:
            dp[i+1][j] = dp[i][j] j >= c[i] j c[i] c i dp[i+1][j] = min(dp[i+1][j-c[i]] + 1, dp[i][j]) dp[i+1][j] [i+1] dp i+1 i 1 j min(dp[i+1][j-c[i]] + 1, dp[i][j]) min dp[i+1][j-c[i]] + 1 dp[i+1][j-c[i]] [i+1] dp i+1 i 1 j-c[i] j c[i] c i 1 dp[i][j] [i] dp i j dp[i+1][j] = dp[i][j] dp[i+1][j] [i+1] dp i+1 i 1 j dp[i][j] [i] dp i j print(dp[m][n]) print dp[m][n] [m] dp m n ni = lambda: int(ns()) lambda: int(ns()) ni inf = 10**20 10**20 inf stdin = sys.stdin sys.stdin stdin c = na() na() c mod = 10**9 + 7 10**9 + 7 mod n, m = na() na() n m = na() na() m na = lambda: list(map(int, stdin.readline().split())) lambda: list(map(int, stdin.readline().split())) na ns = lambda: stdin.readline().rstrip() lambda: stdin.readline().rstrip() ns dp = [[100000000] * (50001) for _ in range(20+1)] [[100000000] * (50001) for _ in range(20+1)] dp
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

from collections import deque
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
c = na()
dp = [[100000000] * (50001) for _ in range(20+1)]
for i in range(20+1):
    dp[i][0] = 0
for i in range(m):
    for j in range(n+1):
        if j >= c[i]:
            dp[i+1][j] = min(dp[i+1][j-c[i]] + 1, dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[m][n])
