# -*- coding: utf-8 -*-

import sys

sys.setrecursionlimit(10 ** 9)
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()))
INF=float('inf')

N,M=MAP()
C=LIST()

dp=[INF]*(N+1)
dp[0]=0
for i in range(N):
    for j in range(M):
        if i+C[j]<=N:
            dp[i+C[j]]=min(dp[i+C[j]], dp[i]+1)
print(dp[N])
 import sys sys sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 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 INF=float('inf') INF float('inf') float 'inf' 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):
    for j in range(M):
        if i+C[j]<=N:
            dp[i+C[j]]=min(dp[i+C[j]], dp[i]+1) i range(N) range N for j in range(M):
        if i+C[j]<=N:
            dp[i+C[j]]=min(dp[i+C[j]], dp[i]+1) j range(M) range M if i+C[j]<=N:
            dp[i+C[j]]=min(dp[i+C[j]], dp[i]+1) i+C[j]<=N i+C[j] i C[j] C j N dp[i+C[j]]=min(dp[i+C[j]], dp[i]+1) dp[i+C[j]] dp i+C[j] i C[j] C j min(dp[i+C[j]], dp[i]+1) min dp[i+C[j]] dp i+C[j] i C[j] C j dp[i]+1 dp[i] dp i 1 print(dp[N]) print dp[N] dp N dp=[INF]*(N+1) [INF]*(N+1) dp def input(): return sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() input C=LIST() LIST() C def MAP(): return map(int, input().split()) def MAP(): return map(int, input().split()) MAP M=MAP() MAP() M def INT(): return int(input()) def INT(): return int(input()) INT def LIST(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) LIST INF=float('inf') float('inf') INF N,M=MAP() MAP() N
# -*- coding: utf-8 -*-

import sys

sys.setrecursionlimit(10 ** 9)
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()))
INF=float('inf')

N,M=MAP()
C=LIST()

dp=[INF]*(N+1)
dp[0]=0
for i in range(N):
    for j in range(M):
        if i+C[j]<=N:
            dp[i+C[j]]=min(dp[i+C[j]], dp[i]+1)
print(dp[N])

