# -*- coding: utf-8 -*-
N, M = tuple(map(int, input().split()))
coins = sorted(tuple(map(int, input().split())))

counts = [float("inf") for _ in range(N+1)]
counts[0] = 0

for m in range(M):
    coin = coins[m]
    for n in range(coin, N+1):
        counts[n] = min(counts[n], counts[n-coin] + 1)

print(counts[-1]) N, M = tuple(map(int, input().split())) N tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split M coins = sorted(tuple(map(int, input().split()))) coins sorted(tuple(map(int, input().split()))) sorted tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split float("inf") for _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) float("inf") float "inf" counts = [float("inf") for _ in range(N+1)] counts [float("inf") for _ in range(N+1)] counts[0] = 0 counts[0] counts 0 0 for m in range(M):
    coin = coins[m]
    for n in range(coin, N+1):
        counts[n] = min(counts[n], counts[n-coin] + 1) m range(M) range M coin = coins[m] coin coins[m] coins m for n in range(coin, N+1):
        counts[n] = min(counts[n], counts[n-coin] + 1) n range(coin, N+1) range coin N+1 N 1 counts[n] = min(counts[n], counts[n-coin] + 1) counts[n] counts n min(counts[n], counts[n-coin] + 1) min counts[n] counts n counts[n-coin] + 1 counts[n-coin] counts n-coin n coin 1 print(counts[-1]) print counts[-1] counts -1 M = tuple(map(int, input().split())) tuple(map(int, input().split())) M coin = coins[m] coins[m] coin coins = sorted(tuple(map(int, input().split()))) sorted(tuple(map(int, input().split()))) coins N, M = tuple(map(int, input().split())) tuple(map(int, input().split())) N counts = [float("inf") for _ in range(N+1)] [float("inf") for _ in range(N+1)] counts
# -*- coding: utf-8 -*-
N, M = tuple(map(int, input().split()))
coins = sorted(tuple(map(int, input().split())))

counts = [float("inf") for _ in range(N+1)]
counts[0] = 0

for m in range(M):
    coin = coins[m]
    for n in range(coin, N+1):
        counts[n] = min(counts[n], counts[n-coin] + 1)

print(counts[-1])