def solve(n, m, c):
    dp = [0] + [float("inf")] * n
    for i in range(1, n + 1):
        added_val = float("inf")
        for coin in c:
            added_val = min(added_val, dp[i - coin]) if 0 <= i - coin else added_val
        dp[i] = min(dp[i], added_val + 1)
    print(dp[n])

if __name__ == "__main__":
    n, m = map(int, input().split())
    c = list(map(int, input().split()))
    solve(n, m, c) def solve(n, m, c):
    dp = [0] + [float("inf")] * n
    for i in range(1, n + 1):
        added_val = float("inf")
        for coin in c:
            added_val = min(added_val, dp[i - coin]) if 0 <= i - coin else added_val
        dp[i] = min(dp[i], added_val + 1)
    print(dp[n]) solve dp = [0] + [float("inf")] * n dp [0] + [float("inf")] * n [0] 0 [float("inf")] * n [float("inf")] float("inf") float "inf" n for i in range(1, n + 1):
        added_val = float("inf")
        for coin in c:
            added_val = min(added_val, dp[i - coin]) if 0 <= i - coin else added_val
        dp[i] = min(dp[i], added_val + 1)
     i range(1, n + 1) range 1 n + 1 n 1 added_val = float("inf") added_val float("inf") float "inf" for coin in c:
            added_val = min(added_val, dp[i - coin]) if 0 <= i - coin else added_val
         coin c added_val = min(added_val, dp[i - coin]) if 0 <= i - coin else added_val added_val min(added_val, dp[i - coin]) if 0 <= i - coin else added_val 0 <= i - coin 0 i - coin i coin min(added_val, dp[i - coin]) min added_val dp[i - coin] dp i - coin i coin added_val dp[i] = min(dp[i], added_val + 1) dp[i] dp i min(dp[i], added_val + 1) min dp[i] dp i added_val + 1 added_val 1 print(dp[n]) print dp[n] dp n n n m m c c if __name__ == "__main__":
    n, m = map(int, input().split())
    c = list(map(int, input().split()))
    solve(n, m, c) __name__ == "__main__" __name__ "__main__" 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 solve(n, m, c) solve n m c 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 solve(n, m, c):
    dp = [0] + [float("inf")] * n
    for i in range(1, n + 1):
        added_val = float("inf")
        for coin in c:
            added_val = min(added_val, dp[i - coin]) if 0 <= i - coin else added_val
        dp[i] = min(dp[i], added_val + 1)
    print(dp[n]) def solve(n, m, c):
    dp = [0] + [float("inf")] * n
    for i in range(1, n + 1):
        added_val = float("inf")
        for coin in c:
            added_val = min(added_val, dp[i - coin]) if 0 <= i - coin else added_val
        dp[i] = min(dp[i], added_val + 1)
    print(dp[n]) solve
def solve(n, m, c):
    dp = [0] + [float("inf")] * n
    for i in range(1, n + 1):
        added_val = float("inf")
        for coin in c:
            added_val = min(added_val, dp[i - coin]) if 0 <= i - coin else added_val
        dp[i] = min(dp[i], added_val + 1)
    print(dp[n])

if __name__ == "__main__":
    n, m = map(int, input().split())
    c = list(map(int, input().split()))
    solve(n, m, c)
