N, M = map(int, input().split())
C = list(map(int, input().split()))
INF = 10**9
dp = [INF]*(N+1)
dp[0] = 0
for i in range(M):
    for n in range(N+1):
        if n >= C[i]:
            dp[n] = min(dp[n], dp[n-C[i]]+1)
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 dp = [INF]*(N+1) dp [INF]*(N+1) [INF] INF N+1 N 1 dp[0] = 0 dp[0] dp 0 0 for i in range(M):
    for n in range(N+1):
        if n >= C[i]:
            dp[n] = min(dp[n], dp[n-C[i]]+1) i range(M) range M for n in range(N+1):
        if n >= C[i]:
            dp[n] = min(dp[n], dp[n-C[i]]+1) n range(N+1) range N+1 N 1 if n >= C[i]:
            dp[n] = min(dp[n], dp[n-C[i]]+1) n >= C[i] n C[i] C i dp[n] = min(dp[n], dp[n-C[i]]+1) dp[n] dp n min(dp[n], dp[n-C[i]]+1) min dp[n] dp n dp[n-C[i]]+1 dp[n-C[i]] dp n-C[i] n C[i] C i 1 print(dp[N]) print dp[N] dp N C = list(map(int, input().split())) list(map(int, input().split())) C dp = [INF]*(N+1) [INF]*(N+1) dp N, M = map(int, input().split()) map(int, input().split()) N INF = 10**9 10**9 INF M = map(int, input().split()) map(int, input().split()) M
N, M = map(int, input().split())
C = list(map(int, input().split()))
INF = 10**9
dp = [INF]*(N+1)
dp[0] = 0
for i in range(M):
    for n in range(N+1):
        if n >= C[i]:
            dp[n] = min(dp[n], dp[n-C[i]]+1)
print(dp[N])
