I=input().split( )
n=int(I[0])
m=int(I[1])

C=input().split( )
c=[int(C[i]) for i in range(m)]

T=[50001 for i in range(n+1)]#50000が上限
T[0]=0

for i in range(m):
    for j in range(n+1):
        if c[i]+j<=n:
            T[j+c[i]]=min(T[j+c[i]],T[j]+1)

print(T[n])
 I=input().split( ) I input().split( ) ().split () input split n=int(I[0]) n int(I[0]) int I[0] I 0 m=int(I[1]) m int(I[1]) int I[1] I 1 C=input().split( ) C input().split( ) ().split () input split int(C[i]) for i in range(m) for i in range(m) i range(m) range m for i in range(m) int(C[i]) int C[i] C i c=[int(C[i]) for i in range(m)] c [int(C[i]) for i in range(m)] 50001 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) 50001 T=[50001 for i in range(n+1)] T [50001 for i in range(n+1)] T[0]=0 T[0] T 0 0 for i in range(m):
    for j in range(n+1):
        if c[i]+j<=n:
            T[j+c[i]]=min(T[j+c[i]],T[j]+1) i range(m) range m for j in range(n+1):
        if c[i]+j<=n:
            T[j+c[i]]=min(T[j+c[i]],T[j]+1) j range(n+1) range n+1 n 1 if c[i]+j<=n:
            T[j+c[i]]=min(T[j+c[i]],T[j]+1) c[i]+j<=n c[i]+j c[i] c i j n T[j+c[i]]=min(T[j+c[i]],T[j]+1) T[j+c[i]] T j+c[i] j c[i] c i min(T[j+c[i]],T[j]+1) min T[j+c[i]] T j+c[i] j c[i] c i T[j]+1 T[j] T j 1 print(T[n]) print T[n] T n n=int(I[0]) int(I[0]) n I=input().split( ) input().split( ) I m=int(I[1]) int(I[1]) m C=input().split( ) input().split( ) C T=[50001 for i in range(n+1)] [50001 for i in range(n+1)] T c=[int(C[i]) for i in range(m)] [int(C[i]) for i in range(m)] c
I=input().split( )
n=int(I[0])
m=int(I[1])

C=input().split( )
c=[int(C[i]) for i in range(m)]

T=[50001 for i in range(n+1)]#50000が上限
T[0]=0

for i in range(m):
    for j in range(n+1):
        if c[i]+j<=n:
            T[j+c[i]]=min(T[j+c[i]],T[j]+1)

print(T[n])

