def solver(n ,m, coins):
  dp = [[100000] * (n + 1) for i in range(m + 1)]
  for i in range(m + 1): dp[i][0] = 0
  for r in range(1, m + 1):
    for c in range(1, n + 1):
      if 0 > c - coins[r - 1]:
        dp[r][c] = dp[r - 1][c]
      else:
        dp[r][c] = min(dp[r - 1][c], dp[r][c - coins[r - 1]] + 1)
  print(dp[m][n])


n, m = map(int, input().split())
coins = sorted(list(map(int, input().split())))
solver(n, m, coins) def solver(n ,m, coins):
  dp = [[100000] * (n + 1) for i in range(m + 1)]
  for i in range(m + 1): dp[i][0] = 0
  for r in range(1, m + 1):
    for c in range(1, n + 1):
      if 0 > c - coins[r - 1]:
        dp[r][c] = dp[r - 1][c]
      else:
        dp[r][c] = min(dp[r - 1][c], dp[r][c - coins[r - 1]] + 1)
  print(dp[m][n]) solver [100000] * (n + 1) for i in range(m + 1) for i in range(m + 1) i range(m + 1) range m + 1 m 1 for i in range(m + 1) [100000] * (n + 1) [100000] 100000 n + 1 n 1 dp = [[100000] * (n + 1) for i in range(m + 1)] dp [[100000] * (n + 1) for i in range(m + 1)] for i in range(m + 1): dp[i][0] = 0
   i range(m + 1) range m + 1 m 1 for r in range(1, m + 1):
    for c in range(1, n + 1):
      if 0 > c - coins[r - 1]:
        dp[r][c] = dp[r - 1][c]
      else:
        dp[r][c] = min(dp[r - 1][c], dp[r][c - coins[r - 1]] + 1)
   r range(1, m + 1) range 1 m + 1 m 1 for c in range(1, n + 1):
      if 0 > c - coins[r - 1]:
        dp[r][c] = dp[r - 1][c]
      else:
        dp[r][c] = min(dp[r - 1][c], dp[r][c - coins[r - 1]] + 1)
   c range(1, n + 1) range 1 n + 1 n 1 if 0 > c - coins[r - 1]:
        dp[r][c] = dp[r - 1][c]
      else:
        dp[r][c] = min(dp[r - 1][c], dp[r][c - coins[r - 1]] + 1)
   0 > c - coins[r - 1] 0 c - coins[r - 1] c coins[r - 1] coins r - 1 r 1 dp[r][c] = dp[r - 1][c] dp[r][c] [r] dp r c dp[r - 1][c] [r - 1] dp r - 1 r 1 c dp[r][c] = min(dp[r - 1][c], dp[r][c - coins[r - 1]] + 1) dp[r][c] [r] dp r c min(dp[r - 1][c], dp[r][c - coins[r - 1]] + 1) min dp[r - 1][c] [r - 1] dp r - 1 r 1 c dp[r][c - coins[r - 1]] + 1 dp[r][c - coins[r - 1]] [r] dp r c - coins[r - 1] c coins[r - 1] coins r - 1 r 1 1 print(dp[m][n]) print dp[m][n] [m] dp m n n n m m coins coins n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m coins = sorted(list(map(int, input().split()))) coins sorted(list(map(int, input().split()))) sorted list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split solver(n, m, coins) solver n m coins def solver(n ,m, coins):
  dp = [[100000] * (n + 1) for i in range(m + 1)]
  for i in range(m + 1): dp[i][0] = 0
  for r in range(1, m + 1):
    for c in range(1, n + 1):
      if 0 > c - coins[r - 1]:
        dp[r][c] = dp[r - 1][c]
      else:
        dp[r][c] = min(dp[r - 1][c], dp[r][c - coins[r - 1]] + 1)
  print(dp[m][n]) def solver(n ,m, coins):
  dp = [[100000] * (n + 1) for i in range(m + 1)]
  for i in range(m + 1): dp[i][0] = 0
  for r in range(1, m + 1):
    for c in range(1, n + 1):
      if 0 > c - coins[r - 1]:
        dp[r][c] = dp[r - 1][c]
      else:
        dp[r][c] = min(dp[r - 1][c], dp[r][c - coins[r - 1]] + 1)
  print(dp[m][n]) solver n, m = map(int, input().split()) map(int, input().split()) n coins = sorted(list(map(int, input().split()))) sorted(list(map(int, input().split()))) coins m = map(int, input().split()) map(int, input().split()) m
def solver(n ,m, coins):
  dp = [[100000] * (n + 1) for i in range(m + 1)]
  for i in range(m + 1): dp[i][0] = 0
  for r in range(1, m + 1):
    for c in range(1, n + 1):
      if 0 > c - coins[r - 1]:
        dp[r][c] = dp[r - 1][c]
      else:
        dp[r][c] = min(dp[r - 1][c], dp[r][c - coins[r - 1]] + 1)
  print(dp[m][n])


n, m = map(int, input().split())
coins = sorted(list(map(int, input().split())))
solver(n, m, coins)
