# coding: utf-8
# Your code here!
INF = 2000000000

def getTheNumberOfCoin():
    for i in range(n + 1):
        T.append(INF)
    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




T = []
C = []
nums=list(map(int,input().split()))
n = nums[0]
m = nums[1]
nums=list(map(int,input().split()))
for i in range(m):
    C.append(nums[i])

getTheNumberOfCoin()
print(T[n])




 INF = 2000000000 INF 2000000000 def getTheNumberOfCoin():
    for i in range(n + 1):
        T.append(INF)
    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 getTheNumberOfCoin for i in range(n + 1):
        T.append(INF)
     i range(n + 1) range n + 1 n 1 T.append(INF) T.append T append INF 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 T T = [] T [] C = [] C [] nums=list(map(int,input().split())) nums list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split n = nums[0] n nums[0] nums 0 m = nums[1] m nums[1] nums 1 nums=list(map(int,input().split())) nums list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for i in range(m):
    C.append(nums[i]) i range(m) range m C.append(nums[i]) C.append C append nums[i] nums i getTheNumberOfCoin() getTheNumberOfCoin print(T[n]) print T[n] T n def getTheNumberOfCoin():
    for i in range(n + 1):
        T.append(INF)
    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 def getTheNumberOfCoin():
    for i in range(n + 1):
        T.append(INF)
    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 getTheNumberOfCoin C = [] [] C m = nums[1] nums[1] m n = nums[0] nums[0] n nums=list(map(int,input().split())) list(map(int,input().split())) nums nums=list(map(int,input().split())) list(map(int,input().split())) nums INF = 2000000000 2000000000 INF T = [] [] T
# coding: utf-8
# Your code here!
INF = 2000000000

def getTheNumberOfCoin():
    for i in range(n + 1):
        T.append(INF)
    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




T = []
C = []
nums=list(map(int,input().split()))
n = nums[0]
m = nums[1]
nums=list(map(int,input().split()))
for i in range(m):
    C.append(nums[i])

getTheNumberOfCoin()
print(T[n])





