n, m = map(int, input().split())
C = list(map(int, input().split()))
dp = [-1] * (n+1)

for c in C:
    if c <= n:
        dp[c] = 1

for p in range(1, n+1):
    for c in C:
        if p-c < 0 or dp[p-c] < 0:
            continue
        dp[p] = min(dp[p], dp[p-c] + 1) if dp[p] > 0 else dp[p-c] + 1

# print(*dp)
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 dp = [-1] * (n+1) dp [-1] * (n+1) [-1] -1 n+1 n 1 for c in C:
    if c <= n:
        dp[c] = 1 c C if c <= n:
        dp[c] = 1 c <= n c n dp[c] = 1 dp[c] dp c 1 for p in range(1, n+1):
    for c in C:
        if p-c < 0 or dp[p-c] < 0:
            continue
        dp[p] = min(dp[p], dp[p-c] + 1) if dp[p] > 0 else dp[p-c] + 1

# print(*dp) p range(1, n+1) range 1 n+1 n 1 for c in C:
        if p-c < 0 or dp[p-c] < 0:
            continue
        dp[p] = min(dp[p], dp[p-c] + 1) if dp[p] > 0 else dp[p-c] + 1

# print(*dp) c C if p-c < 0 or dp[p-c] < 0:
            continue
         p-c < 0 or dp[p-c] < 0 p-c < 0 p-c p c 0 dp[p-c] < 0 dp[p-c] dp p-c p c 0 continue dp[p] = min(dp[p], dp[p-c] + 1) if dp[p] > 0 else dp[p-c] + 1 dp[p] dp p min(dp[p], dp[p-c] + 1) if dp[p] > 0 else dp[p-c] + 1 dp[p] > 0 dp[p] dp p 0 min(dp[p], dp[p-c] + 1) min dp[p] dp p dp[p-c] + 1 dp[p-c] dp p-c p c 1 dp[p-c] + 1 dp[p-c] dp p-c p c 1 print(dp[n]) print dp[n] dp n dp = [-1] * (n+1) [-1] * (n+1) dp C = list(map(int, input().split())) list(map(int, input().split())) C 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())
C = list(map(int, input().split()))
dp = [-1] * (n+1)

for c in C:
    if c <= n:
        dp[c] = 1

for p in range(1, n+1):
    for c in C:
        if p-c < 0 or dp[p-c] < 0:
            continue
        dp[p] = min(dp[p], dp[p-c] + 1) if dp[p] > 0 else dp[p-c] + 1

# print(*dp)
print(dp[n])

