# 37

N, M = map(int, input().split())
C_L = [int(x) for x in input().split()]

# dp[i] = i円の支払う時のコインの最小枚数
dp = [float("Inf")] * (N+1)
dp[0] = 0
for i in range(1, N+1):
    for j in range(M):
        _c = C_L[j]
        if i >= _c:
            dp[i] = min(dp[i-_c] + 1, dp[i])

print(dp[N])
 N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x C_L = [int(x) for x in input().split()] C_L [int(x) for x in input().split()] 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(1, N+1):
    for j in range(M):
        _c = C_L[j]
        if i >= _c:
            dp[i] = min(dp[i-_c] + 1, dp[i]) i range(1, N+1) range 1 N+1 N 1 for j in range(M):
        _c = C_L[j]
        if i >= _c:
            dp[i] = min(dp[i-_c] + 1, dp[i]) j range(M) range M _c = C_L[j] _c C_L[j] C_L j if i >= _c:
            dp[i] = min(dp[i-_c] + 1, dp[i]) i >= _c i _c dp[i] = min(dp[i-_c] + 1, dp[i]) dp[i] dp i min(dp[i-_c] + 1, dp[i]) min dp[i-_c] + 1 dp[i-_c] dp i-_c i _c 1 dp[i] dp i print(dp[N]) print dp[N] dp N C_L = [int(x) for x in input().split()] [int(x) for x in input().split()] C_L dp = [float("Inf")] * (N+1) [float("Inf")] * (N+1) dp _c = C_L[j] C_L[j] _c M = map(int, input().split()) map(int, input().split()) M N, M = map(int, input().split()) map(int, input().split()) N
# 37

N, M = map(int, input().split())
C_L = [int(x) for x in input().split()]

# dp[i] = i円の支払う時のコインの最小枚数
dp = [float("Inf")] * (N+1)
dp[0] = 0
for i in range(1, N+1):
    for j in range(M):
        _c = C_L[j]
        if i >= _c:
            dp[i] = min(dp[i-_c] + 1, dp[i])

print(dp[N])

