N, M = map(int, input().split())
C = tuple(map(int, input().split()))

inf = 10**18
dp = [inf] * (N + 10)
dp[0] = 0

for c in C:
    for i in range(c, N + 1):
        dp[i] = min(dp[i], dp[i - c] + 1)
ans = dp[N]
print(ans) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M C = tuple(map(int, input().split())) C tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split inf = 10**18 inf 10**18 10 18 dp = [inf] * (N + 10) dp [inf] * (N + 10) [inf] inf N + 10 N 10 dp[0] = 0 dp[0] dp 0 0 for c in C:
    for i in range(c, N + 1):
        dp[i] = min(dp[i], dp[i - c] + 1) c C for i in range(c, N + 1):
        dp[i] = min(dp[i], dp[i - c] + 1) i range(c, N + 1) range c N + 1 N 1 dp[i] = min(dp[i], dp[i - c] + 1) dp[i] dp i min(dp[i], dp[i - c] + 1) min dp[i] dp i dp[i - c] + 1 dp[i - c] dp i - c i c 1 ans = dp[N] ans dp[N] dp N print(ans) print ans C = tuple(map(int, input().split())) tuple(map(int, input().split())) C N, M = map(int, input().split()) map(int, input().split()) N inf = 10**18 10**18 inf ans = dp[N] dp[N] ans M = map(int, input().split()) map(int, input().split()) M dp = [inf] * (N + 10) [inf] * (N + 10) dp
N, M = map(int, input().split())
C = tuple(map(int, input().split()))

inf = 10**18
dp = [inf] * (N + 10)
dp[0] = 0

for c in C:
    for i in range(c, N + 1):
        dp[i] = min(dp[i], dp[i - c] + 1)
ans = dp[N]
print(ans)
