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

# 0はdummy
dp = [50001 for _ in range(50001)]
dp[0] = 0

for i in range(0,50001):
    for j in range(m):
        if i+coins[j] <= n:
            dp[i+coins[j]] = min(dp[i+coins[j]],dp[i]+1)
            
print(dp[n])
         n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m coins = list(map(int,input().split())) coins list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split 50001 for _ in range(50001) for _ in range(50001) _ range(50001) range 50001 for _ in range(50001) 50001 dp = [50001 for _ in range(50001)] dp [50001 for _ in range(50001)] dp[0] = 0 dp[0] dp 0 0 for i in range(0,50001):
    for j in range(m):
        if i+coins[j] <= n:
            dp[i+coins[j]] = min(dp[i+coins[j]],dp[i]+1)
             i range(0,50001) range 0 50001 for j in range(m):
        if i+coins[j] <= n:
            dp[i+coins[j]] = min(dp[i+coins[j]],dp[i]+1)
             j range(m) range m if i+coins[j] <= n:
            dp[i+coins[j]] = min(dp[i+coins[j]],dp[i]+1)
             i+coins[j] <= n i+coins[j] i coins[j] coins j n dp[i+coins[j]] = min(dp[i+coins[j]],dp[i]+1) dp[i+coins[j]] dp i+coins[j] i coins[j] coins j min(dp[i+coins[j]],dp[i]+1) min dp[i+coins[j]] dp i+coins[j] i coins[j] coins j dp[i]+1 dp[i] dp i 1 print(dp[n]) print dp[n] dp n coins = list(map(int,input().split())) list(map(int,input().split())) coins dp = [50001 for _ in range(50001)] [50001 for _ in range(50001)] dp m = map(int,input().split()) map(int,input().split()) m n,m = map(int,input().split()) map(int,input().split()) n
n,m = map(int,input().split())
coins = list(map(int,input().split()))

# 0はdummy
dp = [50001 for _ in range(50001)]
dp[0] = 0

for i in range(0,50001):
    for j in range(m):
        if i+coins[j] <= n:
            dp[i+coins[j]] = min(dp[i+coins[j]],dp[i]+1)
            
print(dp[n])
        
