def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n, m = MAP()
c = LIST()

price = [float("INF")] * (n+1)
price[0] = 0

for i in range(n+1):
    for j in range(m):
        if i - c[j] < 0:
            continue
        price[i] = min(price[i], price[i-c[j]] + 1)

print(price[-1])

 def INT(): return int(input()) INT def MAP(): return map(int, input().split()) MAP def LIST(): return list(map(int, input().split())) LIST n, m = MAP() n MAP() MAP m c = LIST() c LIST() LIST price = [float("INF")] * (n+1) price [float("INF")] * (n+1) [float("INF")] float("INF") float "INF" n+1 n 1 price[0] = 0 price[0] price 0 0 for i in range(n+1):
    for j in range(m):
        if i - c[j] < 0:
            continue
        price[i] = min(price[i], price[i-c[j]] + 1) i range(n+1) range n+1 n 1 for j in range(m):
        if i - c[j] < 0:
            continue
        price[i] = min(price[i], price[i-c[j]] + 1) j range(m) range m if i - c[j] < 0:
            continue
         i - c[j] < 0 i - c[j] i c[j] c j 0 continue price[i] = min(price[i], price[i-c[j]] + 1) price[i] price i min(price[i], price[i-c[j]] + 1) min price[i] price i price[i-c[j]] + 1 price[i-c[j]] price i-c[j] i c[j] c j 1 print(price[-1]) print price[-1] price -1 def MAP(): return map(int, input().split()) def MAP(): return map(int, input().split()) MAP def INT(): return int(input()) def INT(): return int(input()) INT def LIST(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) LIST price = [float("INF")] * (n+1) [float("INF")] * (n+1) price n, m = MAP() MAP() n c = LIST() LIST() c m = MAP() MAP() m
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n, m = MAP()
c = LIST()

price = [float("INF")] * (n+1)
price[0] = 0

for i in range(n+1):
    for j in range(m):
        if i - c[j] < 0:
            continue
        price[i] = min(price[i], price[i-c[j]] + 1)

print(price[-1])


