import math
n, m = map(int,input().split(' '))
d = list(map(int,input().split(' ')))
d.sort()
inf = n

dp = [ [ inf for i in range(m+1)] for j in range(n+1) ]

# dp
for j in range(m+1):
    dp[0][j]=0

for j in range(m-1,-1,-1):
    for i in range(n+1):
        #for k in range(math.floor(i/d[j])+1):
        if math.floor(i/d[j]) >=1:
            k=1
        else:
            k=0
        r = k*d[j]
        #print(i,j,k)
        dp[i][j] = min( dp[i][j], dp[i][j+1], dp[i-r][j]+k ) 
        #print("dp:",i,j,dp[i][j])
print(dp[n][0])
 import math math n, m = map(int,input().split(' ')) n map(int,input().split(' ')) map int input().split(' ') ().split () input split ' ' m d = list(map(int,input().split(' '))) d list(map(int,input().split(' '))) list map(int,input().split(' ')) map int input().split(' ') ().split () input split ' ' d.sort() d.sort d sort inf = n inf n [ inf for i in range(m+1)] for j in range(n+1) for j in range(n+1) j range(n+1) range n+1 n 1 for j in range(n+1) [ inf for i in range(m+1)] dp = [ [ inf for i in range(m+1)] for j in range(n+1) ] dp [ [ inf for i in range(m+1)] for j in range(n+1) ] for j in range(m+1):
    dp[0][j]=0 j range(m+1) range m+1 m 1 dp[0][j]=0 dp[0][j] [0] dp 0 j 0 for j in range(m-1,-1,-1):
    for i in range(n+1):
        #for k in range(math.floor(i/d[j])+1):
        if math.floor(i/d[j]) >=1:
            k=1
        else:
            k=0
        r = k*d[j]
        #print(i,j,k)
        dp[i][j] = min( dp[i][j], dp[i][j+1], dp[i-r][j]+k ) 
        #print("dp:",i,j,dp[i][j]) j range(m-1,-1,-1) range m-1 m 1 -1 -1 for i in range(n+1):
        #for k in range(math.floor(i/d[j])+1):
        if math.floor(i/d[j]) >=1:
            k=1
        else:
            k=0
        r = k*d[j]
        #print(i,j,k)
        dp[i][j] = min( dp[i][j], dp[i][j+1], dp[i-r][j]+k ) 
        #print("dp:",i,j,dp[i][j]) i range(n+1) range n+1 n 1 if math.floor(i/d[j]) >=1:
            k=1
        else:
            k=0
         math.floor(i/d[j]) >=1 math.floor(i/d[j]) math.floor math floor i/d[j] i d[j] d j 1 k=1 k 1 k=0 k 0 r = k*d[j] r k*d[j] k d[j] d j dp[i][j] = min( dp[i][j], dp[i][j+1], dp[i-r][j]+k ) dp[i][j] [i] dp i j min( dp[i][j], dp[i][j+1], dp[i-r][j]+k ) min dp[i][j] [i] dp i j dp[i][j+1] [i] dp i j+1 j 1 dp[i-r][j]+k dp[i-r][j] [i-r] dp i-r i r j k print(dp[n][0]) print dp[n][0] [n] dp n 0 d = list(map(int,input().split(' '))) list(map(int,input().split(' '))) d r = k*d[j] k*d[j] r n, m = map(int,input().split(' ')) map(int,input().split(' ')) n m = map(int,input().split(' ')) map(int,input().split(' ')) m k=0 0 k k=1 1 k inf = n n inf dp = [ [ inf for i in range(m+1)] for j in range(n+1) ] [ [ inf for i in range(m+1)] for j in range(n+1) ] dp
import math
n, m = map(int,input().split(' '))
d = list(map(int,input().split(' ')))
d.sort()
inf = n

dp = [ [ inf for i in range(m+1)] for j in range(n+1) ]

# dp
for j in range(m+1):
    dp[0][j]=0

for j in range(m-1,-1,-1):
    for i in range(n+1):
        #for k in range(math.floor(i/d[j])+1):
        if math.floor(i/d[j]) >=1:
            k=1
        else:
            k=0
        r = k*d[j]
        #print(i,j,k)
        dp[i][j] = min( dp[i][j], dp[i][j+1], dp[i-r][j]+k ) 
        #print("dp:",i,j,dp[i][j])
print(dp[n][0])

