n, m = map(int, input().split())
c = list(map(int, input().split()))
c.sort() # sortしなくてもこのアルゴリズムは有効

dp = [50001 for i in range(n + 1)]
dp[0] = 0

for i in c:
  for j in range(i, n + 1):
    dp[j] = min(dp[j], dp[j - 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 c.sort() c.sort c sort 50001 for i in range(n + 1) for i in range(n + 1) i range(n + 1) range n + 1 n 1 for i in range(n + 1) 50001 dp = [50001 for i in range(n + 1)] dp [50001 for i in range(n + 1)] dp[0] = 0 dp[0] dp 0 0 for i in c:
  for j in range(i, n + 1):
    dp[j] = min(dp[j], dp[j - i] + 1)
     i c for j in range(i, n + 1):
    dp[j] = min(dp[j], dp[j - i] + 1)
     j range(i, n + 1) range i n + 1 n 1 dp[j] = min(dp[j], dp[j - i] + 1) dp[j] dp j min(dp[j], dp[j - i] + 1) min dp[j] dp j dp[j - i] + 1 dp[j - i] dp j - i j i 1 print(dp[n]) print dp[n] dp n c = list(map(int, input().split())) list(map(int, input().split())) c m = map(int, input().split()) map(int, input().split()) m dp = [50001 for i in range(n + 1)] [50001 for i in range(n + 1)] dp n, m = map(int, input().split()) map(int, input().split()) n
n, m = map(int, input().split())
c = list(map(int, input().split()))
c.sort() # sortしなくてもこのアルゴリズムは有効

dp = [50001 for i in range(n + 1)]
dp[0] = 0

for i in c:
  for j in range(i, n + 1):
    dp[j] = min(dp[j], dp[j - i] + 1)
    
print(dp[n])
