# -*- coding: utf-8 -*-
"""
Created on Sat May 26 12:16:54 2018
DPL-1A Rec Call Revised
@author: maezawa
"""

n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
c.sort()
dp = [float('inf') for _ in range(n+1)]
dp[0] = 0
#print(n,m)
#print(c)
#print(*dp, sep='\n')

for j in range(1,n+1):
    temp = []
    for i in range(m):
        if j < c[i]:
            continue
        else:
            temp.append(dp[j-c[i]]+1)
    dp[j] = min(temp)

print(dp[n]) """
Created on Sat May 26 12:16:54 2018
DPL-1A Rec Call Revised
@author: maezawa
""" n, m = list(map(int, input().split())) n list(map(int, input().split())) list 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 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 j in range(1,n+1):
    temp = []
    for i in range(m):
        if j < c[i]:
            continue
        else:
            temp.append(dp[j-c[i]]+1)
    dp[j] = min(temp) j range(1,n+1) range 1 n+1 n 1 temp = [] temp [] for i in range(m):
        if j < c[i]:
            continue
        else:
            temp.append(dp[j-c[i]]+1)
     i range(m) range m if j < c[i]:
            continue
        else:
            temp.append(dp[j-c[i]]+1)
     j < c[i] j c[i] c i continue temp.append(dp[j-c[i]]+1) temp.append temp append dp[j-c[i]]+1 dp[j-c[i]] dp j-c[i] j c[i] c i 1 dp[j] = min(temp) dp[j] dp j min(temp) min temp print(dp[n]) print dp[n] dp n temp = [] [] temp dp = [float('inf') for _ in range(n+1)] [float('inf') for _ in range(n+1)] dp m = list(map(int, input().split())) list(map(int, input().split())) m n, m = list(map(int, input().split())) list(map(int, input().split())) n c = list(map(int, input().split())) list(map(int, input().split())) c
# -*- coding: utf-8 -*-
"""
Created on Sat May 26 12:16:54 2018
DPL-1A Rec Call Revised
@author: maezawa
"""

n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
c.sort()
dp = [float('inf') for _ in range(n+1)]
dp[0] = 0
#print(n,m)
#print(c)
#print(*dp, sep='\n')

for j in range(1,n+1):
    temp = []
    for i in range(m):
        if j < c[i]:
            continue
        else:
            temp.append(dp[j-c[i]]+1)
    dp[j] = min(temp)

print(dp[n])
