#!/usr/bin/env python
# -*- coding: utf-8 -*-

import itertools as ite
import math
import random
import sys
import codecs
from collections import defaultdict

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

n, m = map(int, input().split())
c = list(map(int, input().split()))
DP = [0] + [n] * n
for i in range(m):
    for j in range(c[i], n + 1):
        DP[j] = min(DP[j], DP[j - c[i]] + 1)
print(DP[n])
 import itertools as ite itertools import math math import random random import sys sys import codecs codecs from collections import defaultdict sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 INF = 10 ** 18 INF 10 ** 18 10 18 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 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 = [0] + [n] * n DP [0] + [n] * n [0] 0 [n] * n [n] n n for i in range(m):
    for j in range(c[i], n + 1):
        DP[j] = min(DP[j], DP[j - c[i]] + 1) i range(m) range m for j in range(c[i], n + 1):
        DP[j] = min(DP[j], DP[j - c[i]] + 1) j range(c[i], n + 1) range c[i] c i n + 1 n 1 DP[j] = min(DP[j], DP[j - c[i]] + 1) DP[j] DP j min(DP[j], DP[j - c[i]] + 1) min DP[j] DP j DP[j - c[i]] + 1 DP[j - c[i]] DP j - c[i] j c[i] c i 1 print(DP[n]) print DP[n] DP n c = list(map(int, input().split())) list(map(int, input().split())) c INF = 10 ** 18 10 ** 18 INF m = map(int, input().split()) map(int, input().split()) m DP = [0] + [n] * n [0] + [n] * n DP MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD n, m = map(int, input().split()) map(int, input().split()) n
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import itertools as ite
import math
import random
import sys
import codecs
from collections import defaultdict

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

n, m = map(int, input().split())
c = list(map(int, input().split()))
DP = [0] + [n] * n
for i in range(m):
    for j in range(c[i], n + 1):
        DP[j] = min(DP[j], DP[j - c[i]] + 1)
print(DP[n])

