def count_changes(money, coins):
  memo=[None for _ in range(money+1)]
  memo[0]=0
 
  def dy_program(change):
    for total in range(1, change+1):
      min_val=total
      for coin in coins:
        if total >= coin:
          res=memo[total-coin]
          min_val=min(res, min_val)
      memo[total]=min_val+1
    return memo[change]
  return dy_program(money)
 
mo=int(input())
n=int(input())
arr=[0]*(n+1)
arr=list(map(int, input().split()))
 
print(count_changes(mo,arr)) 

+ Recent posts