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

INF = 10**9
MAX = n + 1
dp = [INF for _ in range(MAX)]
dp[0] = 0
for i in range(m):
    for j in range(len(dp)):
        if j + c[i] < MAX:
            dp[j+c[i]] = min(dp[j] + 1, dp[j+c[i]])

min_v = dp[-1]
for i in range(len(dp)):
    idx = len(dp) - 1 - i
    min_v = min(min_v, dp[idx])
    dp[idx] = min_v

print(dp[n])
 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 INF = 10**9 INF 10**9 10 9 MAX = n + 1 MAX n + 1 n 1 INF for _ in range(MAX) for _ in range(MAX) _ range(MAX) range MAX for _ in range(MAX) INF dp = [INF for _ in range(MAX)] dp [INF for _ in range(MAX)] dp[0] = 0 dp[0] dp 0 0 for i in range(m):
    for j in range(len(dp)):
        if j + c[i] < MAX:
            dp[j+c[i]] = min(dp[j] + 1, dp[j+c[i]]) i range(m) range m for j in range(len(dp)):
        if j + c[i] < MAX:
            dp[j+c[i]] = min(dp[j] + 1, dp[j+c[i]]) j range(len(dp)) range len(dp) len dp if j + c[i] < MAX:
            dp[j+c[i]] = min(dp[j] + 1, dp[j+c[i]]) j + c[i] < MAX j + c[i] j c[i] c i MAX dp[j+c[i]] = min(dp[j] + 1, dp[j+c[i]]) dp[j+c[i]] dp j+c[i] j c[i] c i min(dp[j] + 1, dp[j+c[i]]) min dp[j] + 1 dp[j] dp j 1 dp[j+c[i]] dp j+c[i] j c[i] c i min_v = dp[-1] min_v dp[-1] dp -1 for i in range(len(dp)):
    idx = len(dp) - 1 - i
    min_v = min(min_v, dp[idx])
    dp[idx] = min_v i range(len(dp)) range len(dp) len dp idx = len(dp) - 1 - i idx len(dp) - 1 - i len(dp) - 1 len(dp) len dp 1 i min_v = min(min_v, dp[idx]) min_v min(min_v, dp[idx]) min min_v dp[idx] dp idx dp[idx] = min_v dp[idx] dp idx min_v print(dp[n]) print dp[n] dp n c = list(map(int, input().split())) list(map(int, input().split())) c dp = [INF for _ in range(MAX)] [INF for _ in range(MAX)] dp m = map(int, input().split()) map(int, input().split()) m min_v = dp[-1] dp[-1] min_v idx = len(dp) - 1 - i len(dp) - 1 - i idx n, m = map(int, input().split()) map(int, input().split()) n INF = 10**9 10**9 INF min_v = min(min_v, dp[idx]) min(min_v, dp[idx]) min_v MAX = n + 1 n + 1 MAX
n, m = map(int, input().split())
c = list(map(int, input().split()))

INF = 10**9
MAX = n + 1
dp = [INF for _ in range(MAX)]
dp[0] = 0
for i in range(m):
    for j in range(len(dp)):
        if j + c[i] < MAX:
            dp[j+c[i]] = min(dp[j] + 1, dp[j+c[i]])

min_v = dp[-1]
for i in range(len(dp)):
    idx = len(dp) - 1 - i
    min_v = min(min_v, dp[idx])
    dp[idx] = min_v

print(dp[n])

