import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N, M = mi()
C = li()

'''
# 二次元DP
dp = dp2(float('inf'), N+1, M+1)
dp[0][0] = 0
for i in range(1, M+1):
    for j in range(N+1):
        #if j == 0:
            #dp[i][j] = 0
        dp[i][j] = min(dp[i-1][j], dp[i][j])
        c = C[i-1]
        if j+c <= N:
            dp[i][j+c] = min(dp[i][j]+1, dp[i-1][j+c])
#print(dp)
print(dp[M][N])
'''

# 1次元DP
dp = [float('inf') for i in range(N+1)]
dp[0] = 0

for i in range(M):
    for j in range(N+1):
        c = C[i]
        if j+c <= N:
            dp[j+c] = min(dp[j]+1, dp[j+c])

print(dp[N]) import sys sys sys.setrecursionlimit(10**8) sys.setrecursionlimit sys setrecursionlimit 10**8 10 8 def ii(): return int(sys.stdin.readline()) ii def mi(): return map(int, sys.stdin.readline().split()) mi def li(): return list(map(int, sys.stdin.readline().split())) li list(map(int, sys.stdin.readline().split())) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) 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 def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] li2 N N [ini]*i for _ in range(j) for _ in range(j) _ range(j) range j for _ in range(j) [ini]*i [ini] ini i def dp2(ini, i, j): return [[ini]*i for _ in range(j)] dp2 ini ini i i j j [[ini]*i for _ in range(j)] for _ in range(k) for _ in range(k) _ range(k) range k for _ in range(k) [[ini]*i for _ in range(j)] def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A)) dp3 ini ini i i j j k k N, M = mi() N mi() mi M C = li() C li() li '''
# 二次元DP
dp = dp2(float('inf'), N+1, M+1)
dp[0][0] = 0
for i in range(1, M+1):
    for j in range(N+1):
        #if j == 0:
            #dp[i][j] = 0
        dp[i][j] = min(dp[i-1][j], dp[i][j])
        c = C[i-1]
        if j+c <= N:
            dp[i][j+c] = min(dp[i][j]+1, dp[i-1][j+c])
#print(dp)
print(dp[M][N])
''' float('inf') for i in range(N+1) for i in range(N+1) i range(N+1) range N+1 N 1 for i in range(N+1) float('inf') float 'inf' dp = [float('inf') for i in range(N+1)] dp [float('inf') for i in range(N+1)] dp[0] = 0 dp[0] dp 0 0 for i in range(M):
    for j in range(N+1):
        c = C[i]
        if j+c <= N:
            dp[j+c] = min(dp[j]+1, dp[j+c]) i range(M) range M for j in range(N+1):
        c = C[i]
        if j+c <= N:
            dp[j+c] = min(dp[j]+1, dp[j+c]) j range(N+1) range N+1 N 1 c = C[i] c C[i] C i if j+c <= N:
            dp[j+c] = min(dp[j]+1, dp[j+c]) j+c <= N j+c j c N dp[j+c] = min(dp[j]+1, dp[j+c]) dp[j+c] dp j+c j c min(dp[j]+1, dp[j+c]) min dp[j]+1 dp[j] dp j 1 dp[j+c] dp j+c j c print(dp[N]) print dp[N] dp N M = mi() mi() M N, M = mi() mi() N dp = [float('inf') for i in range(N+1)] [float('inf') for i in range(N+1)] dp def li(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) li C = li() li() C def ii(): return int(sys.stdin.readline()) def ii(): return int(sys.stdin.readline()) ii def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A)) def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A)) dp3 def mi(): return map(int, sys.stdin.readline().split()) def mi(): return map(int, sys.stdin.readline().split()) mi def dp2(ini, i, j): return [[ini]*i for _ in range(j)] def dp2(ini, i, j): return [[ini]*i for _ in range(j)] dp2 c = C[i] C[i] c def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] li2
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N, M = mi()
C = li()

'''
# 二次元DP
dp = dp2(float('inf'), N+1, M+1)
dp[0][0] = 0
for i in range(1, M+1):
    for j in range(N+1):
        #if j == 0:
            #dp[i][j] = 0
        dp[i][j] = min(dp[i-1][j], dp[i][j])
        c = C[i-1]
        if j+c <= N:
            dp[i][j+c] = min(dp[i][j]+1, dp[i-1][j+c])
#print(dp)
print(dp[M][N])
'''

# 1次元DP
dp = [float('inf') for i in range(N+1)]
dp[0] = 0

for i in range(M):
    for j in range(N+1):
        c = C[i]
        if j+c <= N:
            dp[j+c] = min(dp[j]+1, dp[j+c])

print(dp[N])
