n,m = map(int,input().split())
c = list(map(int,input().split()))
i = 0
dp = [0] * 50001
for i in range(50001):
    dp[i] = i
#金額ごとに最小枚数を出す
for i in range(2,n+1):
    for j in range(m):
        if i - c[j] >= 0:
            dp[i] = min(dp[i], dp[i - c[j]] + 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 i = 0 i 0 dp = [0] * 50001 dp [0] * 50001 [0] 0 50001 for i in range(50001):
    dp[i] = i
#金額ごとに最小枚数を出す i range(50001) range 50001 dp[i] = i dp[i] dp i i for i in range(2,n+1):
    for j in range(m):
        if i - c[j] >= 0:
            dp[i] = min(dp[i], dp[i - c[j]] + 1) i range(2,n+1) range 2 n+1 n 1 for j in range(m):
        if i - c[j] >= 0:
            dp[i] = min(dp[i], dp[i - c[j]] + 1) j range(m) range m if i - c[j] >= 0:
            dp[i] = min(dp[i], dp[i - c[j]] + 1) i - c[j] >= 0 i - c[j] i c[j] c j 0 dp[i] = min(dp[i], dp[i - c[j]] + 1) dp[i] dp i min(dp[i], dp[i - c[j]] + 1) min dp[i] dp i dp[i - c[j]] + 1 dp[i - c[j]] dp i - c[j] i c[j] c j 1 print(dp[n]) print dp[n] dp n m = map(int,input().split()) map(int,input().split()) m i = 0 0 i c = list(map(int,input().split())) list(map(int,input().split())) c n,m = map(int,input().split()) map(int,input().split()) n dp = [0] * 50001 [0] * 50001 dp
n,m = map(int,input().split())
c = list(map(int,input().split()))
i = 0
dp = [0] * 50001
for i in range(50001):
    dp[i] = i
#金額ごとに最小枚数を出す
for i in range(2,n+1):
    for j in range(m):
        if i - c[j] >= 0:
            dp[i] = min(dp[i], dp[i - c[j]] + 1)

print(dp[n])
