n,m=map(int,input().split())
C=list(map(int,input().split()))

dp=[[float('inf')]*(n+1) for i in range(m+1)]
for i in range(m+1):
    dp[i][0]=0

for i in range(1,m+1):
    c=C[i-1]
    for j in range(1,n+1):
        dp[i][j]=dp[i-1][j]
        if j>=c:
            dp[i][j]=min(dp[i][j],dp[i-1][j-c]+1,dp[i][j-c]+1)

print(dp[m][n])
         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 [float('inf')]*(n+1) for i in range(m+1) for i in range(m+1) i range(m+1) range m+1 m 1 for i in range(m+1) [float('inf')]*(n+1) [float('inf')] float('inf') float 'inf' n+1 n 1 dp=[[float('inf')]*(n+1) for i in range(m+1)] dp [[float('inf')]*(n+1) for i in range(m+1)] for i in range(m+1):
    dp[i][0]=0 i range(m+1) range m+1 m 1 dp[i][0]=0 dp[i][0] [i] dp i 0 0 for i in range(1,m+1):
    c=C[i-1]
    for j in range(1,n+1):
        dp[i][j]=dp[i-1][j]
        if j>=c:
            dp[i][j]=min(dp[i][j],dp[i-1][j-c]+1,dp[i][j-c]+1) i range(1,m+1) range 1 m+1 m 1 c=C[i-1] c C[i-1] C i-1 i 1 for j in range(1,n+1):
        dp[i][j]=dp[i-1][j]
        if j>=c:
            dp[i][j]=min(dp[i][j],dp[i-1][j-c]+1,dp[i][j-c]+1) j range(1,n+1) range 1 n+1 n 1 dp[i][j]=dp[i-1][j] dp[i][j] [i] dp i j dp[i-1][j] [i-1] dp i-1 i 1 j if j>=c:
            dp[i][j]=min(dp[i][j],dp[i-1][j-c]+1,dp[i][j-c]+1) j>=c j c dp[i][j]=min(dp[i][j],dp[i-1][j-c]+1,dp[i][j-c]+1) dp[i][j] [i] dp i j min(dp[i][j],dp[i-1][j-c]+1,dp[i][j-c]+1) min dp[i][j] [i] dp i j dp[i-1][j-c]+1 dp[i-1][j-c] [i-1] dp i-1 i 1 j-c j c 1 dp[i][j-c]+1 dp[i][j-c] [i] dp i j-c j c 1 print(dp[m][n]) print dp[m][n] [m] dp m n C=list(map(int,input().split())) list(map(int,input().split())) C c=C[i-1] C[i-1] c dp=[[float('inf')]*(n+1) for i in range(m+1)] [[float('inf')]*(n+1) for i in range(m+1)] dp n,m=map(int,input().split()) map(int,input().split()) n m=map(int,input().split()) map(int,input().split()) m
n,m=map(int,input().split())
C=list(map(int,input().split()))

dp=[[float('inf')]*(n+1) for i in range(m+1)]
for i in range(m+1):
    dp[i][0]=0

for i in range(1,m+1):
    c=C[i-1]
    for j in range(1,n+1):
        dp[i][j]=dp[i-1][j]
        if j>=c:
            dp[i][j]=min(dp[i][j],dp[i-1][j-c]+1,dp[i][j-c]+1)

print(dp[m][n])
        
