#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

n, m = LI()
c = LI()
c = sorted(c)

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

for i in range(n+1):
    for coin in c:
        if (i+coin <= n) and (dp[i+coin] > dp[i]+1):
            dp[i+coin] = dp[i]+1

print(dp[n]) from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys sys import math math import bisect bisect import random random def LI(): return list(map(int, sys.stdin.readline().split())) LI def I(): return int(sys.stdin.readline()) I def LS():return list(map(list, sys.stdin.readline().split())) LS def S(): return list(sys.stdin.readline())[:-1] S def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l IR None for i in range(n) for i in range(n) i range(n) range n for i in range(n) None l = [None for i in range(n)] l [None for i in range(n)] for i in range(n):l[i] = I()
     i range(n) range n return l l n n def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l LIR None for i in range(n) for i in range(n) i range(n) range n for i in range(n) None l = [None for i in range(n)] l [None for i in range(n)] for i in range(n):l[i] = LI()
     i range(n) range n return l l n n def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l SR None for i in range(n) for i in range(n) i range(n) range n for i in range(n) None l = [None for i in range(n)] l [None for i in range(n)] for i in range(n):l[i] = S()
     i range(n) range n return l l n n def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l LSR None for i in range(n) for i in range(n) i range(n) range n for i in range(n) None l = [None for i in range(n)] l [None for i in range(n)] for i in range(n):l[i] = LS()
     i range(n) range n return l l n n sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 mod = 1000000007 mod 1000000007 dire4 = [(1,0), (0,1), (-1,0), (0,-1)] dire4 [(1,0), (0,1), (-1,0), (0,-1)] (1,0) 1 0 (0,1) 0 1 (-1,0) -1 0 (0,-1) 0 -1 dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)] dire8 [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)] (1, 0) 1 0 (1, 1) 1 1 (0, 1) 0 1 (-1, 1) -1 1 (-1, 0) -1 0 (-1, -1) -1 -1 (0, -1) 0 -1 (1, -1) 1 -1 n, m = LI() n LI() LI m c = LI() c LI() LI c = sorted(c) c sorted(c) sorted c dp = [n+1]*(n+1) dp [n+1]*(n+1) [n+1] n+1 n 1 n+1 n 1 dp[0] = 0 dp[0] dp 0 0 for i in range(n+1):
    for coin in c:
        if (i+coin <= n) and (dp[i+coin] > dp[i]+1):
            dp[i+coin] = dp[i]+1 i range(n+1) range n+1 n 1 for coin in c:
        if (i+coin <= n) and (dp[i+coin] > dp[i]+1):
            dp[i+coin] = dp[i]+1 coin c if (i+coin <= n) and (dp[i+coin] > dp[i]+1):
            dp[i+coin] = dp[i]+1 (i+coin <= n) and (dp[i+coin] > dp[i]+1) i+coin <= n i+coin i coin n dp[i+coin] > dp[i]+1 dp[i+coin] dp i+coin i coin dp[i]+1 dp[i] dp i 1 dp[i+coin] = dp[i]+1 dp[i+coin] dp i+coin i coin dp[i]+1 dp[i] dp i 1 print(dp[n]) print dp[n] dp n m = LI() LI() m dp = [n+1]*(n+1) [n+1]*(n+1) dp n, m = LI() LI() n def LI(): return list(map(int, sys.stdin.readline().split())) def LI(): return list(map(int, sys.stdin.readline().split())) LI def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l IR def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l LIR def LS():return list(map(list, sys.stdin.readline().split())) def LS():return list(map(list, sys.stdin.readline().split())) LS def I(): return int(sys.stdin.readline()) def I(): return int(sys.stdin.readline()) I def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l SR c = sorted(c) sorted(c) c def S(): return list(sys.stdin.readline())[:-1] def S(): return list(sys.stdin.readline())[:-1] S def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l LSR mod = 1000000007 1000000007 mod dire4 = [(1,0), (0,1), (-1,0), (0,-1)] [(1,0), (0,1), (-1,0), (0,-1)] dire4 c = LI() LI() c dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)] [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)] dire8
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

n, m = LI()
c = LI()
c = sorted(c)

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

for i in range(n+1):
    for coin in c:
        if (i+coin <= n) and (dp[i+coin] > dp[i]+1):
            dp[i+coin] = dp[i]+1

print(dp[n])
