n,m = map(int,input().split())
L = list(map(int,input().split()))
dp = [float('inf')]*50001
for i in range(len(L)):
    dp[L[i]] = 1
for i in range(2,50001):
    for j in range(len(L)):
        if i-L[j] >= 1:
            dp[i] = min(dp[i-L[j]]+1,dp[i])
print(dp[n]) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m L = list(map(int,input().split())) L list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split dp = [float('inf')]*50001 dp [float('inf')]*50001 [float('inf')] float('inf') float 'inf' 50001 for i in range(len(L)):
    dp[L[i]] = 1 i range(len(L)) range len(L) len L dp[L[i]] = 1 dp[L[i]] dp L[i] L i 1 for i in range(2,50001):
    for j in range(len(L)):
        if i-L[j] >= 1:
            dp[i] = min(dp[i-L[j]]+1,dp[i]) i range(2,50001) range 2 50001 for j in range(len(L)):
        if i-L[j] >= 1:
            dp[i] = min(dp[i-L[j]]+1,dp[i]) j range(len(L)) range len(L) len L if i-L[j] >= 1:
            dp[i] = min(dp[i-L[j]]+1,dp[i]) i-L[j] >= 1 i-L[j] i L[j] L j 1 dp[i] = min(dp[i-L[j]]+1,dp[i]) dp[i] dp i min(dp[i-L[j]]+1,dp[i]) min dp[i-L[j]]+1 dp[i-L[j]] dp i-L[j] i L[j] L j 1 dp[i] dp i print(dp[n]) print dp[n] dp n dp = [float('inf')]*50001 [float('inf')]*50001 dp L = list(map(int,input().split())) list(map(int,input().split())) L 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())
L = list(map(int,input().split()))
dp = [float('inf')]*50001
for i in range(len(L)):
    dp[L[i]] = 1
for i in range(2,50001):
    for j in range(len(L)):
        if i-L[j] >= 1:
            dp[i] = min(dp[i-L[j]]+1,dp[i])
print(dp[n])
