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

INF = 10**9

dp = [INF for _ in range(n+1)] #dp[i] := i円での最小枚数
dp[0] = 0
for i in range(m):
    if C[i] < n+1:
        dp[C[i]] = 1

for i in range(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 INF = 10**9 INF 10**9 10 9 INF for _ in range(n+1) for _ in range(n+1) _ range(n+1) range n+1 n 1 for _ in range(n+1) INF dp = [INF for _ in range(n+1)] dp [INF for _ in range(n+1)] dp[0] = 0 dp[0] dp 0 0 for i in range(m):
    if C[i] < n+1:
        dp[C[i]] = 1 i range(m) range m if C[i] < n+1:
        dp[C[i]] = 1 C[i] < n+1 C[i] C i n+1 n 1 dp[C[i]] = 1 dp[C[i]] dp C[i] C i 1 for i in range(n+1):
    for j in range(m):
        if i-C[j] >= 0:
            dp[i] = min(dp[i],dp[i-C[j]] + 1) i range(n+1) range 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 n,m = map(int,input().split()) map(int,input().split()) n INF = 10**9 10**9 INF m = map(int,input().split()) map(int,input().split()) m dp = [INF for _ in range(n+1)] [INF for _ in range(n+1)] dp C = list(map(int,input().split())) list(map(int,input().split())) C
n,m = map(int,input().split())
C = list(map(int,input().split()))

INF = 10**9

dp = [INF for _ in range(n+1)] #dp[i] := i円での最小枚数
dp[0] = 0
for i in range(m):
    if C[i] < n+1:
        dp[C[i]] = 1

for i in range(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])

