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

print(dp[N])
