n, m = map(int, input().split())
C = list(map(int, input().split()))

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

print(coin())
 n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m C = list(map(int, input().split())) C list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split def coin():
    dp = [float('inf')]*(n+1)
    dp[0] = 0
    for i in range(m):
        for j in range(C[i], n+1):
            dp[j] = min(dp[j], dp[j-C[i]]+1)
    return dp[n] coin dp = [float('inf')]*(n+1) dp [float('inf')]*(n+1) [float('inf')] float('inf') float 'inf' n+1 n 1 dp[0] = 0 dp[0] dp 0 0 for i in range(m):
        for j in range(C[i], n+1):
            dp[j] = min(dp[j], dp[j-C[i]]+1)
     i range(m) range m for j in range(C[i], n+1):
            dp[j] = min(dp[j], dp[j-C[i]]+1)
     j range(C[i], n+1) range C[i] C i n+1 n 1 dp[j] = min(dp[j], dp[j-C[i]]+1) dp[j] dp j min(dp[j], dp[j-C[i]]+1) min dp[j] dp j dp[j-C[i]]+1 dp[j-C[i]] dp j-C[i] j C[i] C i 1 return dp[n] dp[n] dp n print(coin()) print coin() coin m = map(int, input().split()) map(int, input().split()) m C = list(map(int, input().split())) list(map(int, input().split())) C n, m = map(int, input().split()) map(int, input().split()) n def coin():
    dp = [float('inf')]*(n+1)
    dp[0] = 0
    for i in range(m):
        for j in range(C[i], n+1):
            dp[j] = min(dp[j], dp[j-C[i]]+1)
    return dp[n] def coin():
    dp = [float('inf')]*(n+1)
    dp[0] = 0
    for i in range(m):
        for j in range(C[i], n+1):
            dp[j] = min(dp[j], dp[j-C[i]]+1)
    return dp[n] coin
n, m = map(int, input().split())
C = list(map(int, input().split()))

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

print(coin())

