import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline()[:-1]
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]

def main():
    inf=10**6
    n,m=MI()
    cc=LI()
    dp=[inf]*(n+1)
    dp[0]=0
    for c in cc:
        for i in range(n-c+1):
            if dp[i]==inf:continue
            if dp[i]+1<dp[i+c]:dp[i+c]=dp[i]+1
    print(dp[-1])

main()
 import sys sys sys.setrecursionlimit(10 ** 6) sys.setrecursionlimit sys setrecursionlimit 10 ** 6 10 6 from bisect import * from collections import * from heapq import * int1 = lambda x: int(x) - 1 int1 lambda x: int(x) - 1 int(x) - 1 int(x) int x 1 x p2D = lambda x: print(*x, sep="\n") p2D lambda x: print(*x, sep="\n") print(*x, sep="\n") print *x x sep="\n" sep "\n" x def II(): return int(sys.stdin.readline()) II def SI(): return sys.stdin.readline()[:-1] SI def MI(): return map(int, sys.stdin.readline().split()) MI def MI1(): return map(int1, sys.stdin.readline().split()) MI1 def MF(): return map(float, sys.stdin.readline().split()) MF def LI(): return list(map(int, sys.stdin.readline().split())) LI def LI1(): return list(map(int1, sys.stdin.readline().split())) LI1 def LF(): return list(map(float, sys.stdin.readline().split())) LF LI() for _ in range(rows_number) for _ in range(rows_number) _ range(rows_number) range rows_number for _ in range(rows_number) LI() LI def LLI(rows_number): return [LI() for _ in range(rows_number)] LLI rows_number rows_number dij = [(0, 1), (1, 0), (0, -1), (-1, 0)] dij [(0, 1), (1, 0), (0, -1), (-1, 0)] (0, 1) 0 1 (1, 0) 1 0 (0, -1) 0 -1 (-1, 0) -1 0 def main():
    inf=10**6
    n,m=MI()
    cc=LI()
    dp=[inf]*(n+1)
    dp[0]=0
    for c in cc:
        for i in range(n-c+1):
            if dp[i]==inf:continue
            if dp[i]+1<dp[i+c]:dp[i+c]=dp[i]+1
    print(dp[-1]) main inf=10**6 inf 10**6 10 6 n,m=MI() n MI() MI m cc=LI() cc LI() LI dp=[inf]*(n+1) dp [inf]*(n+1) [inf] inf n+1 n 1 dp[0]=0 dp[0] dp 0 0 for c in cc:
        for i in range(n-c+1):
            if dp[i]==inf:continue
            if dp[i]+1<dp[i+c]:dp[i+c]=dp[i]+1
     c cc for i in range(n-c+1):
            if dp[i]==inf:continue
            if dp[i]+1<dp[i+c]:dp[i+c]=dp[i]+1
     i range(n-c+1) range n-c+1 n-c n c 1 if dp[i]==inf:continue
             dp[i]==inf dp[i] dp i inf if dp[i]+1<dp[i+c]:dp[i+c]=dp[i]+1
     dp[i]+1<dp[i+c] dp[i]+1 dp[i] dp i 1 dp[i+c] dp i+c i c print(dp[-1]) print dp[-1] dp -1 main() main def SI(): return sys.stdin.readline()[:-1] def SI(): return sys.stdin.readline()[:-1] SI def main():
    inf=10**6
    n,m=MI()
    cc=LI()
    dp=[inf]*(n+1)
    dp[0]=0
    for c in cc:
        for i in range(n-c+1):
            if dp[i]==inf:continue
            if dp[i]+1<dp[i+c]:dp[i+c]=dp[i]+1
    print(dp[-1]) def main():
    inf=10**6
    n,m=MI()
    cc=LI()
    dp=[inf]*(n+1)
    dp[0]=0
    for c in cc:
        for i in range(n-c+1):
            if dp[i]==inf:continue
            if dp[i]+1<dp[i+c]:dp[i+c]=dp[i]+1
    print(dp[-1]) main p2D = lambda x: print(*x, sep="\n") lambda x: print(*x, sep="\n") p2D def LI(): return list(map(int, sys.stdin.readline().split())) def LI(): return list(map(int, sys.stdin.readline().split())) LI int1 = lambda x: int(x) - 1 lambda x: int(x) - 1 int1 def MI(): return map(int, sys.stdin.readline().split()) def MI(): return map(int, sys.stdin.readline().split()) MI def MI1(): return map(int1, sys.stdin.readline().split()) def MI1(): return map(int1, sys.stdin.readline().split()) MI1 def LI1(): return list(map(int1, sys.stdin.readline().split())) def LI1(): return list(map(int1, sys.stdin.readline().split())) LI1 def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI(rows_number): return [LI() for _ in range(rows_number)] LLI def MF(): return map(float, sys.stdin.readline().split()) def MF(): return map(float, sys.stdin.readline().split()) MF def LF(): return list(map(float, sys.stdin.readline().split())) def LF(): return list(map(float, sys.stdin.readline().split())) LF dij = [(0, 1), (1, 0), (0, -1), (-1, 0)] [(0, 1), (1, 0), (0, -1), (-1, 0)] dij def II(): return int(sys.stdin.readline()) def II(): return int(sys.stdin.readline()) II
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline()[:-1]
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]

def main():
    inf=10**6
    n,m=MI()
    cc=LI()
    dp=[inf]*(n+1)
    dp[0]=0
    for c in cc:
        for i in range(n-c+1):
            if dp[i]==inf:continue
            if dp[i]+1<dp[i+c]:dp[i+c]=dp[i]+1
    print(dp[-1])

main()

