def getTheNumberOfCoin(n,m,C):
    T=[float('inf')]*(n+1)
    T[0]=0

    T=[float('inf')]*(n+1)
    T[0]=0
    for i in range(m):
        for j in range(C[i],n+1):
            T[j] = min(T[j], T[j - C[i]] + 1)
    return T[n]

n,m = map(int,raw_input().split())
C = map(int,raw_input().split())
print getTheNumberOfCoin(n,m,C) def getTheNumberOfCoin(n,m,C):
    T=[float('inf')]*(n+1)
    T[0]=0

    T=[float('inf')]*(n+1)
    T[0]=0
    for i in range(m):
        for j in range(C[i],n+1):
            T[j] = min(T[j], T[j - C[i]] + 1)
    return T[n] getTheNumberOfCoin T=[float('inf')]*(n+1) T [float('inf')]*(n+1) [float('inf')] float('inf') float 'inf' n+1 n 1 T[0]=0 T[0] T 0 0 T=[float('inf')]*(n+1) T [float('inf')]*(n+1) [float('inf')] float('inf') float 'inf' n+1 n 1 T[0]=0 T[0] T 0 0 for i in range(m):
        for j in range(C[i],n+1):
            T[j] = min(T[j], T[j - C[i]] + 1)
     i range(m) range m for j in range(C[i],n+1):
            T[j] = min(T[j], T[j - C[i]] + 1)
     j range(C[i],n+1) range 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 return T[n] T[n] T n n n m m C C n,m = map(int,raw_input().split()) n map(int,raw_input().split()) map int raw_input().split() ().split () raw_input split m C = map(int,raw_input().split()) C map(int,raw_input().split()) map int raw_input().split() ().split () raw_input split print getTheNumberOfCoin(n,m,C) getTheNumberOfCoin n m C n,m = map(int,raw_input().split()) map(int,raw_input().split()) n def getTheNumberOfCoin(n,m,C):
    T=[float('inf')]*(n+1)
    T[0]=0

    T=[float('inf')]*(n+1)
    T[0]=0
    for i in range(m):
        for j in range(C[i],n+1):
            T[j] = min(T[j], T[j - C[i]] + 1)
    return T[n] def getTheNumberOfCoin(n,m,C):
    T=[float('inf')]*(n+1)
    T[0]=0

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

    T=[float('inf')]*(n+1)
    T[0]=0
    for i in range(m):
        for j in range(C[i],n+1):
            T[j] = min(T[j], T[j - C[i]] + 1)
    return T[n]

n,m = map(int,raw_input().split())
C = map(int,raw_input().split())
print getTheNumberOfCoin(n,m,C)