W,N = map(int,input().split())
 
table = [10000000]*(W+1)
 
table[0] = 0
 
coin_list = list(map(int,input().split()))
 
for coin in coin_list:
    for i in range(coin,W+1):
        table[i] = min(table[i],table[i-coin]+1)
 
 
print("%d"%(table[W])) W,N = map(int,input().split()) W map(int,input().split()) map int input().split() ().split () input split N table = [10000000]*(W+1) table [10000000]*(W+1) [10000000] 10000000 W+1 W 1 table[0] = 0 table[0] table 0 0 coin_list = list(map(int,input().split())) coin_list list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for coin in coin_list:
    for i in range(coin,W+1):
        table[i] = min(table[i],table[i-coin]+1)
 
  coin coin_list for i in range(coin,W+1):
        table[i] = min(table[i],table[i-coin]+1)
 
  i range(coin,W+1) range coin W+1 W 1 table[i] = min(table[i],table[i-coin]+1) table[i] table i min(table[i],table[i-coin]+1) min table[i] table i table[i-coin]+1 table[i-coin] table i-coin i coin 1 print("%d"%(table[W])) print "%d"%(table[W]) "%d" table[W] table W W,N = map(int,input().split()) map(int,input().split()) W table = [10000000]*(W+1) [10000000]*(W+1) table N = map(int,input().split()) map(int,input().split()) N coin_list = list(map(int,input().split())) list(map(int,input().split())) coin_list
W,N = map(int,input().split())
 
table = [10000000]*(W+1)
 
table[0] = 0
 
coin_list = list(map(int,input().split()))
 
for coin in coin_list:
    for i in range(coin,W+1):
        table[i] = min(table[i],table[i-coin]+1)
 
 
print("%d"%(table[W]))
