n,m=map(int,input().split())
c=list(map(int,input().split()))
c.sort(reverse=True)
#print(c)

dp=[0]
for i in range(1,n+1):
    mini=float("inf")
    for num in c:
        if i-num>=0:
            mini=min(mini,dp[i-num]+1)
    dp.append(mini)

#print(dp)
print(dp[-1]) 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(reverse=True) c.sort c sort reverse=True reverse True dp=[0] dp [0] 0 for i in range(1,n+1):
    mini=float("inf")
    for num in c:
        if i-num>=0:
            mini=min(mini,dp[i-num]+1)
    dp.append(mini)

#print(dp) i range(1,n+1) range 1 n+1 n 1 mini=float("inf") mini float("inf") float "inf" for num in c:
        if i-num>=0:
            mini=min(mini,dp[i-num]+1)
     num c if i-num>=0:
            mini=min(mini,dp[i-num]+1)
     i-num>=0 i-num i num 0 mini=min(mini,dp[i-num]+1) mini min(mini,dp[i-num]+1) min mini dp[i-num]+1 dp[i-num] dp i-num i num 1 dp.append(mini) dp.append dp append mini print(dp[-1]) print dp[-1] dp -1 mini=float("inf") float("inf") mini m=map(int,input().split()) map(int,input().split()) m c=list(map(int,input().split())) list(map(int,input().split())) c dp=[0] [0] dp mini=min(mini,dp[i-num]+1) min(mini,dp[i-num]+1) mini n,m=map(int,input().split()) map(int,input().split()) n
n,m=map(int,input().split())
c=list(map(int,input().split()))
c.sort(reverse=True)
#print(c)

dp=[0]
for i in range(1,n+1):
    mini=float("inf")
    for num in c:
        if i-num>=0:
            mini=min(mini,dp[i-num]+1)
    dp.append(mini)

#print(dp)
print(dp[-1])
