INF = 10 ** 20

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

lst = list(map(int, input().split()))

dp = [INF for _ in range(n+1)]

dp[0] = 0

for coin in lst:
    for j in range(coin, n+1):
        dp[j] = min(dp[j], dp[j-coin]+1)
print(dp[n]) INF = 10 ** 20 INF 10 ** 20 10 20 n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m lst = list(map(int, input().split())) lst list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split INF for _ in range(n+1) for _ in range(n+1) _ range(n+1) range n+1 n 1 for _ in range(n+1) INF dp = [INF for _ in range(n+1)] dp [INF for _ in range(n+1)] dp[0] = 0 dp[0] dp 0 0 for coin in lst:
    for j in range(coin, n+1):
        dp[j] = min(dp[j], dp[j-coin]+1) coin lst for j in range(coin, n+1):
        dp[j] = min(dp[j], dp[j-coin]+1) j range(coin, n+1) range coin n+1 n 1 dp[j] = min(dp[j], dp[j-coin]+1) dp[j] dp j min(dp[j], dp[j-coin]+1) min dp[j] dp j dp[j-coin]+1 dp[j-coin] dp j-coin j coin 1 print(dp[n]) print dp[n] dp n dp = [INF for _ in range(n+1)] [INF for _ in range(n+1)] dp m = map(int, input().split()) map(int, input().split()) m n, m = map(int, input().split()) map(int, input().split()) n lst = list(map(int, input().split())) list(map(int, input().split())) lst INF = 10 ** 20 10 ** 20 INF
INF = 10 ** 20

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

lst = list(map(int, input().split()))

dp = [INF for _ in range(n+1)]

dp[0] = 0

for coin in lst:
    for j in range(coin, n+1):
        dp[j] = min(dp[j], dp[j-coin]+1)
print(dp[n])
