ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
n,m=mi()
c = li()
dp=list(range(n+1))
for i in c:
    if(i==1):
        continue
    for j in range(i,n+1):
        dp[j] = min(dp[j], dp[j-i]+1)
print(dp[n]) ii = lambda : int(input()) ii lambda : int(input()) int(input()) int input() input mi = lambda : map(int,input().split()) mi lambda : map(int,input().split()) map(int,input().split()) map int input().split() ().split () input split li = lambda : list(map(int,input().split())) li lambda : list(map(int,input().split())) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split n,m=mi() n mi() mi m c = li() c li() li dp=list(range(n+1)) dp list(range(n+1)) list range(n+1) range n+1 n 1 for i in c:
    if(i==1):
        continue
    for j in range(i,n+1):
        dp[j] = min(dp[j], dp[j-i]+1) i c if(i==1):
        continue
     i==1 i 1 continue for j in range(i,n+1):
        dp[j] = min(dp[j], dp[j-i]+1) j range(i,n+1) range i n+1 n 1 dp[j] = min(dp[j], dp[j-i]+1) dp[j] dp j min(dp[j], dp[j-i]+1) min dp[j] dp j dp[j-i]+1 dp[j-i] dp j-i j i 1 print(dp[n]) print dp[n] dp n li = lambda : list(map(int,input().split())) lambda : list(map(int,input().split())) li ii = lambda : int(input()) lambda : int(input()) ii dp=list(range(n+1)) list(range(n+1)) dp c = li() li() c mi = lambda : map(int,input().split()) lambda : map(int,input().split()) mi n,m=mi() mi() n m=mi() mi() m
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
n,m=mi()
c = li()
dp=list(range(n+1))
for i in c:
    if(i==1):
        continue
    for j in range(i,n+1):
        dp[j] = min(dp[j], dp[j-i]+1)
print(dp[n])
