import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

MAX = 10 ** 5
dp = [MAX] * (n + 1)

dp[0] = 0
for i in range(m):
    c = C[i]
    for j in range(n + 1):
        if j >= c:
            dp[j] = min(dp[j], dp[j - c] + 1)
print(dp[n])
 import sys sys import itertools itertools import time time import math math sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 from collections import defaultdict read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines 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 MAX = 10 ** 5 MAX 10 ** 5 10 5 dp = [MAX] * (n + 1) dp [MAX] * (n + 1) [MAX] MAX n + 1 n 1 dp[0] = 0 dp[0] dp 0 0 for i in range(m):
    c = C[i]
    for j in range(n + 1):
        if j >= c:
            dp[j] = min(dp[j], dp[j - c] + 1) i range(m) range m c = C[i] c C[i] C i for j in range(n + 1):
        if j >= c:
            dp[j] = min(dp[j], dp[j - c] + 1) j range(n + 1) range n + 1 n 1 if j >= c:
            dp[j] = min(dp[j], dp[j - c] + 1) j >= c j c dp[j] = min(dp[j], dp[j - c] + 1) dp[j] dp j min(dp[j], dp[j - c] + 1) min dp[j] dp j dp[j - c] + 1 dp[j - c] dp j - c j c 1 print(dp[n]) print dp[n] dp n dp = [MAX] * (n + 1) [MAX] * (n + 1) dp read = sys.stdin.buffer.read sys.stdin.buffer.read read C = list(map(int, input().split())) list(map(int, input().split())) C c = C[i] C[i] c m = map(int, input().split()) map(int, input().split()) m MAX = 10 ** 5 10 ** 5 MAX readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines n, m = map(int, input().split()) map(int, input().split()) n readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

MAX = 10 ** 5
dp = [MAX] * (n + 1)

dp[0] = 0
for i in range(m):
    c = C[i]
    for j in range(n + 1):
        if j >= c:
            dp[j] = min(dp[j], dp[j - c] + 1)
print(dp[n])

