N,M=list(map(int,input().split()))
C=list(map(int,input().split()))
dp=[0]+[50001 for _ in range(N)]


for i in range(M):
  for j in range(C[i],N+1):
    if C[i] > N:
      break
    elif dp[j-C[i]] != 50001:
      dp[j] = min(dp[j],dp[j-C[i]] + 1)

print(dp[N]) N,M=list(map(int,input().split())) N list(map(int,input().split())) list 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 50001 for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) 50001 dp=[0]+[50001 for _ in range(N)] dp [0]+[50001 for _ in range(N)] [0] 0 [50001 for _ in range(N)] for i in range(M):
  for j in range(C[i],N+1):
    if C[i] > N:
      break
    elif dp[j-C[i]] != 50001:
      dp[j] = min(dp[j],dp[j-C[i]] + 1) i range(M) range M for j in range(C[i],N+1):
    if C[i] > N:
      break
    elif dp[j-C[i]] != 50001:
      dp[j] = min(dp[j],dp[j-C[i]] + 1) j range(C[i],N+1) range C[i] C i N+1 N 1 if C[i] > N:
      break
    elif dp[j-C[i]] != 50001:
      dp[j] = min(dp[j],dp[j-C[i]] + 1) C[i] > N C[i] C i N break elif dp[j-C[i]] != 50001:
      dp[j] = min(dp[j],dp[j-C[i]] + 1) dp[j-C[i]] != 50001 dp[j-C[i]] dp j-C[i] j C[i] C i 50001 dp[j] = min(dp[j],dp[j-C[i]] + 1) dp[j] dp j min(dp[j],dp[j-C[i]] + 1) min dp[j] dp j dp[j-C[i]] + 1 dp[j-C[i]] dp j-C[i] j C[i] C i 1 print(dp[N]) print dp[N] dp N M=list(map(int,input().split())) list(map(int,input().split())) M C=list(map(int,input().split())) list(map(int,input().split())) C dp=[0]+[50001 for _ in range(N)] [0]+[50001 for _ in range(N)] dp N,M=list(map(int,input().split())) list(map(int,input().split())) N
N,M=list(map(int,input().split()))
C=list(map(int,input().split()))
dp=[0]+[50001 for _ in range(N)]


for i in range(M):
  for j in range(C[i],N+1):
    if C[i] > N:
      break
    elif dp[j-C[i]] != 50001:
      dp[j] = min(dp[j],dp[j-C[i]] + 1)

print(dp[N])
