N, M = map(int, input().split())
A = list(map(int, input().split()))
memory = [10**6 for _ in range(N + 1)]
flg = [False for _ in range(N + 1)]
memory[0] = 0
flg[0] = True
for a in A:
  m = 0
  while m < len(memory) and m + a < len(memory):
    if flg:
      memory[m + a] = min(memory[m] + 1, memory[m + a])
      flg[m + a] = True
    m += 1
print(memory[-1]) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M A = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split 10**6 for _ in range(N + 1) for _ in range(N + 1) _ range(N + 1) range N + 1 N 1 for _ in range(N + 1) 10**6 10 6 memory = [10**6 for _ in range(N + 1)] memory [10**6 for _ in range(N + 1)] False for _ in range(N + 1) for _ in range(N + 1) _ range(N + 1) range N + 1 N 1 for _ in range(N + 1) False flg = [False for _ in range(N + 1)] flg [False for _ in range(N + 1)] memory[0] = 0 memory[0] memory 0 0 flg[0] = True flg[0] flg 0 True for a in A:
  m = 0
  while m < len(memory) and m + a < len(memory):
    if flg:
      memory[m + a] = min(memory[m] + 1, memory[m + a])
      flg[m + a] = True
    m += 1 a A m = 0 m 0 while m < len(memory) and m + a < len(memory):
    if flg:
      memory[m + a] = min(memory[m] + 1, memory[m + a])
      flg[m + a] = True
    m += 1 m < len(memory) and m + a < len(memory) m < len(memory) m len(memory) len memory m + a < len(memory) m + a m a len(memory) len memory if flg:
      memory[m + a] = min(memory[m] + 1, memory[m + a])
      flg[m + a] = True
     flg memory[m + a] = min(memory[m] + 1, memory[m + a]) memory[m + a] memory m + a m a min(memory[m] + 1, memory[m + a]) min memory[m] + 1 memory[m] memory m 1 memory[m + a] memory m + a m a flg[m + a] = True flg[m + a] flg m + a m a True m += 1 m 1 print(memory[-1]) print memory[-1] memory -1 flg = [False for _ in range(N + 1)] [False for _ in range(N + 1)] flg M = map(int, input().split()) map(int, input().split()) M m = 0 0 m N, M = map(int, input().split()) map(int, input().split()) N A = list(map(int, input().split())) list(map(int, input().split())) A memory = [10**6 for _ in range(N + 1)] [10**6 for _ in range(N + 1)] memory m += 1 1 m
N, M = map(int, input().split())
A = list(map(int, input().split()))
memory = [10**6 for _ in range(N + 1)]
flg = [False for _ in range(N + 1)]
memory[0] = 0
flg[0] = True
for a in A:
  m = 0
  while m < len(memory) and m + a < len(memory):
    if flg:
      memory[m + a] = min(memory[m] + 1, memory[m + a])
      flg[m + a] = True
    m += 1
print(memory[-1])
