def calc_t(i,j):
    global t,c
    if i<0 or j<0:
        return n+2
    #print("get t["+str(i)+","+str(j)+"]")
    if t[i][j]==n+1:
        t[i][j]=min(calc_t(i-1,j),calc_t(i,j-c[i])+1)
    return t[i][j]

ri=raw_input().split(" ")
n=int(ri[0])
m=int(ri[1])
ri=raw_input().split(" ")
c=[0]*m
t=[0]*m
for i in range(m):
    c[i]=int(ri[i])
    t[i]=[0]+[n+1]*n if i!=0 else range(n+1)
c=sorted(c)
#print(c)
#print(t)
for a in range(n+1):
    for b in range(m):
        calc_t(b,a)
print(calc_t(m-1,n)) def calc_t(i,j):
    global t,c
    if i<0 or j<0:
        return n+2
    #print("get t["+str(i)+","+str(j)+"]")
    if t[i][j]==n+1:
        t[i][j]=min(calc_t(i-1,j),calc_t(i,j-c[i])+1)
    return t[i][j] calc_t global t,c if i<0 or j<0:
        return n+2
    #print("get t["+str(i)+","+str(j)+"]")
     i<0 or j<0 i<0 i 0 j<0 j 0 return n+2 n+2 n 2 if t[i][j]==n+1:
        t[i][j]=min(calc_t(i-1,j),calc_t(i,j-c[i])+1)
     t[i][j]==n+1 t[i][j] [i] t i j n+1 n 1 t[i][j]=min(calc_t(i-1,j),calc_t(i,j-c[i])+1) t[i][j] [i] t i j min(calc_t(i-1,j),calc_t(i,j-c[i])+1) min calc_t(i-1,j) calc_t i-1 i 1 j calc_t(i,j-c[i])+1 calc_t(i,j-c[i]) calc_t i j-c[i] j c[i] c i 1 return t[i][j] t[i][j] [i] t i j i i j j ri=raw_input().split(" ") ri raw_input().split(" ") ().split () raw_input split " " n=int(ri[0]) n int(ri[0]) int ri[0] ri 0 m=int(ri[1]) m int(ri[1]) int ri[1] ri 1 ri=raw_input().split(" ") ri raw_input().split(" ") ().split () raw_input split " " c=[0]*m c [0]*m [0] 0 m t=[0]*m t [0]*m [0] 0 m for i in range(m):
    c[i]=int(ri[i])
    t[i]=[0]+[n+1]*n if i!=0 else range(n+1) i range(m) range m c[i]=int(ri[i]) c[i] c i int(ri[i]) int ri[i] ri i t[i]=[0]+[n+1]*n if i!=0 else range(n+1) t[i] t i [0]+[n+1]*n if i!=0 else range(n+1) i!=0 i 0 [0]+[n+1]*n [0] 0 [n+1]*n [n+1] n+1 n 1 n range(n+1) range n+1 n 1 c=sorted(c) c sorted(c) sorted c for a in range(n+1):
    for b in range(m):
        calc_t(b,a) a range(n+1) range n+1 n 1 for b in range(m):
        calc_t(b,a) b range(m) range m calc_t(b,a) calc_t b a print(calc_t(m-1,n)) print calc_t(m-1,n) calc_t m-1 m 1 n n=int(ri[0]) int(ri[0]) n c=[0]*m [0]*m c ri=raw_input().split(" ") raw_input().split(" ") ri m=int(ri[1]) int(ri[1]) m ri=raw_input().split(" ") raw_input().split(" ") ri c=sorted(c) sorted(c) c t=[0]*m [0]*m t def calc_t(i,j):
    global t,c
    if i<0 or j<0:
        return n+2
    #print("get t["+str(i)+","+str(j)+"]")
    if t[i][j]==n+1:
        t[i][j]=min(calc_t(i-1,j),calc_t(i,j-c[i])+1)
    return t[i][j] def calc_t(i,j):
    global t,c
    if i<0 or j<0:
        return n+2
    #print("get t["+str(i)+","+str(j)+"]")
    if t[i][j]==n+1:
        t[i][j]=min(calc_t(i-1,j),calc_t(i,j-c[i])+1)
    return t[i][j] calc_t
def calc_t(i,j):
    global t,c
    if i<0 or j<0:
        return n+2
    #print("get t["+str(i)+","+str(j)+"]")
    if t[i][j]==n+1:
        t[i][j]=min(calc_t(i-1,j),calc_t(i,j-c[i])+1)
    return t[i][j]

ri=raw_input().split(" ")
n=int(ri[0])
m=int(ri[1])
ri=raw_input().split(" ")
c=[0]*m
t=[0]*m
for i in range(m):
    c[i]=int(ri[i])
    t[i]=[0]+[n+1]*n if i!=0 else range(n+1)
c=sorted(c)
#print(c)
#print(t)
for a in range(n+1):
    for b in range(m):
        calc_t(b,a)
print(calc_t(m-1,n))