import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

dp = [INF]*(n+1)
dp[0] = 0

for i in range(n+1):
	for j in c:
		if i-j >= 0:
			dp[i] = min(dp[i], dp[i-j]+1)
# print(dp)
print(dp[n])
 import sys, re sys re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from fractions import gcd def input(): return sys.stdin.readline().strip() input def INT(): return int(input()) INT def MAP(): return map(int, input().split()) MAP def LIST(): return list(map(int, input().split())) LIST sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = float('inf') INF float('inf') float 'inf' mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 n, m = MAP() n MAP() MAP m c = LIST() c LIST() LIST dp = [INF]*(n+1) dp [INF]*(n+1) [INF] INF n+1 n 1 dp[0] = 0 dp[0] dp 0 0 for i in range(n+1):
	for j in c:
		if i-j >= 0:
			dp[i] = min(dp[i], dp[i-j]+1)
# print(dp) i range(n+1) range n+1 n 1 for j in c:
		if i-j >= 0:
			dp[i] = min(dp[i], dp[i-j]+1)
# print(dp) j c if i-j >= 0:
			dp[i] = min(dp[i], dp[i-j]+1)
# print(dp) i-j >= 0 i-j i j 0 dp[i] = min(dp[i], dp[i-j]+1) dp[i] dp i min(dp[i], dp[i-j]+1) min dp[i] dp i dp[i-j]+1 dp[i-j] dp i-j i j 1 print(dp[n]) print dp[n] dp n def input(): return sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() input c = LIST() LIST() c def INT(): return int(input()) def INT(): return int(input()) INT m = MAP() MAP() m n, m = MAP() MAP() n dp = [INF]*(n+1) [INF]*(n+1) dp mod = 10 ** 9 + 7 10 ** 9 + 7 mod INF = float('inf') float('inf') INF def LIST(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) LIST def MAP(): return map(int, input().split()) def MAP(): return map(int, input().split()) MAP
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

dp = [INF]*(n+1)
dp[0] = 0

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

