#A
inf = float("inf")
N,M = map(int,input().split())
C = list(map(int,input().split()))
C.sort()

dp = [inf for i in range(N+1)]
dp[0] = 0
for c in C:
    for p in range(c,N+1):
        dp[p] = min(dp[p],dp[p-c]+1)
        
print(dp[N])


 inf = float("inf") inf float("inf") float "inf" N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M C = list(map(int,input().split())) C list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split C.sort() C.sort C sort inf for i in range(N+1) for i in range(N+1) i range(N+1) range N+1 N 1 for i in range(N+1) inf dp = [inf for i in range(N+1)] dp [inf for i in range(N+1)] dp[0] = 0 dp[0] dp 0 0 for c in C:
    for p in range(c,N+1):
        dp[p] = min(dp[p],dp[p-c]+1)
         c C for p in range(c,N+1):
        dp[p] = min(dp[p],dp[p-c]+1)
         p range(c,N+1) range c N+1 N 1 dp[p] = min(dp[p],dp[p-c]+1) dp[p] dp p min(dp[p],dp[p-c]+1) min dp[p] dp p dp[p-c]+1 dp[p-c] dp p-c p c 1 print(dp[N]) print dp[N] dp N M = map(int,input().split()) map(int,input().split()) M C = list(map(int,input().split())) list(map(int,input().split())) C dp = [inf for i in range(N+1)] [inf for i in range(N+1)] dp N,M = map(int,input().split()) map(int,input().split()) N inf = float("inf") float("inf") inf
#A
inf = float("inf")
N,M = map(int,input().split())
C = list(map(int,input().split()))
C.sort()

dp = [inf for i in range(N+1)]
dp[0] = 0
for c in C:
    for p in range(c,N+1):
        dp[p] = min(dp[p],dp[p-c]+1)
        
print(dp[N])



