n,m=[int(j) for j in input().split()]
c=[int(j) for j in input().split()]
dp=[10**18]*(n+1)
dp[0]=0
for i in c:
    for j in range(i,n+1):
        dp[j]=min(dp[j],dp[j-i]+1)
print(dp[-1]) int(j) for j in input().split() for j in input().split() j input().split() ().split () input split for j in input().split() int(j) int j n,m=[int(j) for j in input().split()] n [int(j) for j in input().split()] m int(j) for j in input().split() for j in input().split() j input().split() ().split () input split for j in input().split() int(j) int j c=[int(j) for j in input().split()] c [int(j) for j in input().split()] dp=[10**18]*(n+1) dp [10**18]*(n+1) [10**18] 10**18 10 18 n+1 n 1 dp[0]=0 dp[0] dp 0 0 for i in c:
    for j in range(i,n+1):
        dp[j]=min(dp[j],dp[j-i]+1) i c for j in range(i,n+1):
        dp[j]=min(dp[j],dp[j-i]+1) j range(i,n+1) range i n+1 n 1 dp[j]=min(dp[j],dp[j-i]+1) dp[j] dp j min(dp[j],dp[j-i]+1) min dp[j] dp j dp[j-i]+1 dp[j-i] dp j-i j i 1 print(dp[-1]) print dp[-1] dp -1 c=[int(j) for j in input().split()] [int(j) for j in input().split()] c dp=[10**18]*(n+1) [10**18]*(n+1) dp n,m=[int(j) for j in input().split()] [int(j) for j in input().split()] n m=[int(j) for j in input().split()] [int(j) for j in input().split()] m
n,m=[int(j) for j in input().split()]
c=[int(j) for j in input().split()]
dp=[10**18]*(n+1)
dp[0]=0
for i in c:
    for j in range(i,n+1):
        dp[j]=min(dp[j],dp[j-i]+1)
print(dp[-1])
