a = raw_input().split()
n = int(a[0])
m = int(a[1])

C = map(int,raw_input().split())
T = [float('inf') for _ in xrange(n+1)]

def getTheNumberOfCoin():
    T[0] = 0
    for i in xrange(m):
        for j in xrange(C[i],n+1):
            T[j] = min(T[j], T[j-C[i]]+1)

    print T[n]
    return 0

getTheNumberOfCoin() a = raw_input().split() a raw_input().split() ().split () raw_input split n = int(a[0]) n int(a[0]) int a[0] a 0 m = int(a[1]) m int(a[1]) int a[1] a 1 C = map(int,raw_input().split()) C map(int,raw_input().split()) map int raw_input().split() ().split () raw_input split float('inf') for _ in xrange(n+1) for _ in xrange(n+1) _ xrange(n+1) xrange n+1 n 1 for _ in xrange(n+1) float('inf') float 'inf' T = [float('inf') for _ in xrange(n+1)] T [float('inf') for _ in xrange(n+1)] def getTheNumberOfCoin():
    T[0] = 0
    for i in xrange(m):
        for j in xrange(C[i],n+1):
            T[j] = min(T[j], T[j-C[i]]+1)

    print T[n]
    return 0 getTheNumberOfCoin T[0] = 0 T[0] T 0 0 for i in xrange(m):
        for j in xrange(C[i],n+1):
            T[j] = min(T[j], T[j-C[i]]+1)

     i xrange(m) xrange m for j in xrange(C[i],n+1):
            T[j] = min(T[j], T[j-C[i]]+1)

     j xrange(C[i],n+1) xrange C[i] C i n+1 n 1 T[j] = min(T[j], T[j-C[i]]+1) T[j] T j min(T[j], T[j-C[i]]+1) min T[j] T j T[j-C[i]]+1 T[j-C[i]] T j-C[i] j C[i] C i 1 print T[n] T n return 0 0 getTheNumberOfCoin() getTheNumberOfCoin a = raw_input().split() raw_input().split() a def getTheNumberOfCoin():
    T[0] = 0
    for i in xrange(m):
        for j in xrange(C[i],n+1):
            T[j] = min(T[j], T[j-C[i]]+1)

    print T[n]
    return 0 def getTheNumberOfCoin():
    T[0] = 0
    for i in xrange(m):
        for j in xrange(C[i],n+1):
            T[j] = min(T[j], T[j-C[i]]+1)

    print T[n]
    return 0 getTheNumberOfCoin n = int(a[0]) int(a[0]) n m = int(a[1]) int(a[1]) m T = [float('inf') for _ in xrange(n+1)] [float('inf') for _ in xrange(n+1)] T C = map(int,raw_input().split()) map(int,raw_input().split()) C
a = raw_input().split()
n = int(a[0])
m = int(a[1])

C = map(int,raw_input().split())
T = [float('inf') for _ in xrange(n+1)]

def getTheNumberOfCoin():
    T[0] = 0
    for i in xrange(m):
        for j in xrange(C[i],n+1):
            T[j] = min(T[j], T[j-C[i]]+1)

    print T[n]
    return 0

getTheNumberOfCoin()