import sys
input = sys.stdin.readline


def inpl():
    return list(map(int, input().split()))


N, M = inpl()
coins = inpl()

dp = [i for i in range(N + 1)]
coins.sort()

for n in range(coins[1], N + 1):
    for c in coins[1:]:
        if c > n:
            continue
        dp[n] = min(dp[n], dp[n - c] + 1)

# print(dp[N])
print(dp[N])
 import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def inpl():
    return list(map(int, input().split())) inpl return list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split N, M = inpl() N inpl() inpl M coins = inpl() coins inpl() inpl i for i in range(N + 1) for i in range(N + 1) i range(N + 1) range N + 1 N 1 for i in range(N + 1) i dp = [i for i in range(N + 1)] dp [i for i in range(N + 1)] coins.sort() coins.sort coins sort for n in range(coins[1], N + 1):
    for c in coins[1:]:
        if c > n:
            continue
        dp[n] = min(dp[n], dp[n - c] + 1)

# print(dp[N]) n range(coins[1], N + 1) range coins[1] coins 1 N + 1 N 1 for c in coins[1:]:
        if c > n:
            continue
        dp[n] = min(dp[n], dp[n - c] + 1)

# print(dp[N]) c coins[1:] coins 1: 1 if c > n:
            continue
         c > n c n continue dp[n] = min(dp[n], dp[n - c] + 1) dp[n] dp n min(dp[n], dp[n - c] + 1) min dp[n] dp n dp[n - c] + 1 dp[n - c] dp n - c n c 1 print(dp[N]) print dp[N] dp N dp = [i for i in range(N + 1)] [i for i in range(N + 1)] dp M = inpl() inpl() M input = sys.stdin.readline sys.stdin.readline input N, M = inpl() inpl() N coins = inpl() inpl() coins def inpl():
    return list(map(int, input().split())) def inpl():
    return list(map(int, input().split())) inpl
import sys
input = sys.stdin.readline


def inpl():
    return list(map(int, input().split()))


N, M = inpl()
coins = inpl()

dp = [i for i in range(N + 1)]
coins.sort()

for n in range(coins[1], N + 1):
    for c in coins[1:]:
        if c > n:
            continue
        dp[n] = min(dp[n], dp[n - c] + 1)

# print(dp[N])
print(dp[N])

