import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

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

dp = [[INF] * (n + 10) for _ in range(m + 10)]
for i in range(m+10):
    dp[i][0] = 0
for i in range(1, n + 1):
    if i % c[0] == 0:
        dp[1][i] = i // c[0]
for i in range(2, m + 1):
    for j in range(1, n + 1):
        if j - c[i - 1] >= 0:
            dp[i][j] = min(dp[i-1][j], dp[i][j - c[i - 1]] + 1)
        else:
            dp[i][j] = dp[i-1][j]
print(dp[m][n]) import sys sys import math math import string string import fractions fractions import random random from operator import itemgetter import itertools itertools from collections import deque import copy copy import heapq heapq import bisect bisect MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 INF = float('inf') INF float('inf') float 'inf' input = lambda: sys.stdin.readline().strip() input lambda: sys.stdin.readline().strip() sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip sys.setrecursionlimit(10 ** 8) sys.setrecursionlimit sys setrecursionlimit 10 ** 8 10 8 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 [INF] * (n + 10) for _ in range(m + 10) for _ in range(m + 10) _ range(m + 10) range m + 10 m 10 for _ in range(m + 10) [INF] * (n + 10) [INF] INF n + 10 n 10 dp = [[INF] * (n + 10) for _ in range(m + 10)] dp [[INF] * (n + 10) for _ in range(m + 10)] for i in range(m+10):
    dp[i][0] = 0 i range(m+10) range m+10 m 10 dp[i][0] = 0 dp[i][0] [i] dp i 0 0 for i in range(1, n + 1):
    if i % c[0] == 0:
        dp[1][i] = i // c[0] i range(1, n + 1) range 1 n + 1 n 1 if i % c[0] == 0:
        dp[1][i] = i // c[0] i % c[0] == 0 i % c[0] i c[0] c 0 0 dp[1][i] = i // c[0] dp[1][i] [1] dp 1 i i // c[0] i c[0] c 0 for i in range(2, m + 1):
    for j in range(1, n + 1):
        if j - c[i - 1] >= 0:
            dp[i][j] = min(dp[i-1][j], dp[i][j - c[i - 1]] + 1)
        else:
            dp[i][j] = dp[i-1][j] i range(2, m + 1) range 2 m + 1 m 1 for j in range(1, n + 1):
        if j - c[i - 1] >= 0:
            dp[i][j] = min(dp[i-1][j], dp[i][j - c[i - 1]] + 1)
        else:
            dp[i][j] = dp[i-1][j] j range(1, n + 1) range 1 n + 1 n 1 if j - c[i - 1] >= 0:
            dp[i][j] = min(dp[i-1][j], dp[i][j - c[i - 1]] + 1)
        else:
            dp[i][j] = dp[i-1][j] j - c[i - 1] >= 0 j - c[i - 1] j c[i - 1] c i - 1 i 1 0 dp[i][j] = min(dp[i-1][j], dp[i][j - c[i - 1]] + 1) dp[i][j] [i] dp i j min(dp[i-1][j], dp[i][j - c[i - 1]] + 1) min dp[i-1][j] [i-1] dp i-1 i 1 j dp[i][j - c[i - 1]] + 1 dp[i][j - c[i - 1]] [i] dp i j - c[i - 1] j c[i - 1] c i - 1 i 1 1 dp[i][j] = dp[i-1][j] dp[i][j] [i] dp i j dp[i-1][j] [i-1] dp i-1 i 1 j print(dp[m][n]) print dp[m][n] [m] dp m n MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD input = lambda: sys.stdin.readline().strip() lambda: sys.stdin.readline().strip() input n, m = map(int, input().split()) map(int, input().split()) n dp = [[INF] * (n + 10) for _ in range(m + 10)] [[INF] * (n + 10) for _ in range(m + 10)] dp INF = float('inf') float('inf') INF c = list(map(int, input().split())) list(map(int, input().split())) c m = map(int, input().split()) map(int, input().split()) m
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

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

dp = [[INF] * (n + 10) for _ in range(m + 10)]
for i in range(m+10):
    dp[i][0] = 0
for i in range(1, n + 1):
    if i % c[0] == 0:
        dp[1][i] = i // c[0]
for i in range(2, m + 1):
    for j in range(1, n + 1):
        if j - c[i - 1] >= 0:
            dp[i][j] = min(dp[i-1][j], dp[i][j - c[i - 1]] + 1)
        else:
            dp[i][j] = dp[i-1][j]
print(dp[m][n])
