import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def MAP(): return [int(s) for s in input().split()]

n,m=MAP()
a=MAP()

#dp[price]=num of coins?

dp=[float('inf') for _ in range(n+1)]
dp[0]=0

for i in range(n+1):
	for j in a:
		if i+j <= n:
			dp[i+j]=min(dp[i]+1,dp[i+j])

print(dp[-1]) import sys sys if sys.platform =='ios':
	sys.stdin=open('Untitled.txt') sys.platform =='ios' sys.platform sys platform 'ios' sys.stdin=open('Untitled.txt') sys.stdin sys stdin open('Untitled.txt') open 'Untitled.txt' input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline int(s) for s in input().split() for s in input().split() s input().split() ().split () input split for s in input().split() int(s) int s def MAP(): return [int(s) for s in input().split()] MAP n,m=MAP() n MAP() MAP m a=MAP() a MAP() MAP float('inf') for _ in range(n+1) for _ in range(n+1) _ range(n+1) range n+1 n 1 for _ in range(n+1) float('inf') float 'inf' dp=[float('inf') for _ in range(n+1)] dp [float('inf') for _ in range(n+1)] dp[0]=0 dp[0] dp 0 0 for i in range(n+1):
	for j in a:
		if i+j <= n:
			dp[i+j]=min(dp[i]+1,dp[i+j]) i range(n+1) range n+1 n 1 for j in a:
		if i+j <= n:
			dp[i+j]=min(dp[i]+1,dp[i+j]) j a if i+j <= n:
			dp[i+j]=min(dp[i]+1,dp[i+j]) i+j <= n i+j i j n dp[i+j]=min(dp[i]+1,dp[i+j]) dp[i+j] dp i+j i j min(dp[i]+1,dp[i+j]) min dp[i]+1 dp[i] dp i 1 dp[i+j] dp i+j i j print(dp[-1]) print dp[-1] dp -1 m=MAP() MAP() m input = sys.stdin.readline sys.stdin.readline input a=MAP() MAP() a dp=[float('inf') for _ in range(n+1)] [float('inf') for _ in range(n+1)] dp n,m=MAP() MAP() n def MAP(): return [int(s) for s in input().split()] def MAP(): return [int(s) for s in input().split()] MAP
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def MAP(): return [int(s) for s in input().split()]

n,m=MAP()
a=MAP()

#dp[price]=num of coins?

dp=[float('inf') for _ in range(n+1)]
dp[0]=0

for i in range(n+1):
	for j in a:
		if i+j <= n:
			dp[i+j]=min(dp[i]+1,dp[i+j])

print(dp[-1])
