n, m = map(int, raw_input().split())
c = map(int, raw_input().split())

t = [float('inf') for i in range(n+1)]
t[0] = 0

for i in range(m):
    if c[i] > n:
        break
    else:
        for j in range(c[i], n+1):
            t[j] = min([t[j], t[j-c[i]]+1])
print t[n] n, m = map(int, raw_input().split()) n map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split m c = map(int, raw_input().split()) c map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split float('inf') for i in range(n+1) for i in range(n+1) i range(n+1) range n+1 n 1 for i in range(n+1) float('inf') float 'inf' t = [float('inf') for i in range(n+1)] t [float('inf') for i in range(n+1)] t[0] = 0 t[0] t 0 0 for i in range(m):
    if c[i] > n:
        break
    else:
        for j in range(c[i], n+1):
            t[j] = min([t[j], t[j-c[i]]+1]) i range(m) range m if c[i] > n:
        break
    else:
        for j in range(c[i], n+1):
            t[j] = min([t[j], t[j-c[i]]+1]) c[i] > n c[i] c i n break for j in range(c[i], n+1):
            t[j] = min([t[j], t[j-c[i]]+1]) j range(c[i], n+1) range c[i] c i n+1 n 1 t[j] = min([t[j], t[j-c[i]]+1]) t[j] t j min([t[j], t[j-c[i]]+1]) min [t[j], t[j-c[i]]+1] t[j] t j t[j-c[i]]+1 t[j-c[i]] t j-c[i] j c[i] c i 1 print t[n] t n n, m = map(int, raw_input().split()) map(int, raw_input().split()) n c = map(int, raw_input().split()) map(int, raw_input().split()) c t = [float('inf') for i in range(n+1)] [float('inf') for i in range(n+1)] t m = map(int, raw_input().split()) map(int, raw_input().split()) m
n, m = map(int, raw_input().split())
c = map(int, raw_input().split())

t = [float('inf') for i in range(n+1)]
t[0] = 0

for i in range(m):
    if c[i] > n:
        break
    else:
        for j in range(c[i], n+1):
            t[j] = min([t[j], t[j-c[i]]+1])
print t[n]