m,n=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
dp=[[int(1e4) for i in range(m+1)] for j in range(n+1)]
i=n-1
while i>=0:
    for j in range(m+1):
        if j==c[i]:
            dp[i][j]=1
        elif j<c[i]:
            dp[i][j]=dp[i+1][j]
        else:
            dp[i][j]=min(dp[i+1][j],dp[i+1][j-c[i]]+1,dp[i][j-c[i]]+1)
    i-=1
print(dp[0][m]) int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i m,n=[int(i) for i in input().split()] m [int(i) for i in input().split()] n int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i c=[int(i) for i in input().split()] c [int(i) for i in input().split()] [int(1e4) for i in range(m+1)] for j in range(n+1) for j in range(n+1) j range(n+1) range n+1 n 1 for j in range(n+1) [int(1e4) for i in range(m+1)] dp=[[int(1e4) for i in range(m+1)] for j in range(n+1)] dp [[int(1e4) for i in range(m+1)] for j in range(n+1)] i=n-1 i n-1 n 1 while i>=0:
    for j in range(m+1):
        if j==c[i]:
            dp[i][j]=1
        elif j<c[i]:
            dp[i][j]=dp[i+1][j]
        else:
            dp[i][j]=min(dp[i+1][j],dp[i+1][j-c[i]]+1,dp[i][j-c[i]]+1)
    i-=1 i>=0 i 0 for j in range(m+1):
        if j==c[i]:
            dp[i][j]=1
        elif j<c[i]:
            dp[i][j]=dp[i+1][j]
        else:
            dp[i][j]=min(dp[i+1][j],dp[i+1][j-c[i]]+1,dp[i][j-c[i]]+1)
     j range(m+1) range m+1 m 1 if j==c[i]:
            dp[i][j]=1
        elif j<c[i]:
            dp[i][j]=dp[i+1][j]
        else:
            dp[i][j]=min(dp[i+1][j],dp[i+1][j-c[i]]+1,dp[i][j-c[i]]+1)
     j==c[i] j c[i] c i dp[i][j]=1 dp[i][j] [i] dp i j 1 elif j<c[i]:
            dp[i][j]=dp[i+1][j]
         j<c[i] j c[i] c i 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 dp[i][j]=min(dp[i+1][j],dp[i+1][j-c[i]]+1,dp[i][j-c[i]]+1) dp[i][j] [i] dp i j min(dp[i+1][j],dp[i+1][j-c[i]]+1,dp[i][j-c[i]]+1) min dp[i+1][j] [i+1] dp i+1 i 1 j dp[i+1][j-c[i]]+1 dp[i+1][j-c[i]] [i+1] dp i+1 i 1 j-c[i] j c[i] c i 1 dp[i][j-c[i]]+1 dp[i][j-c[i]] [i] dp i j-c[i] j c[i] c i 1 i-=1 i 1 print(dp[0][m]) print dp[0][m] [0] dp 0 m i=n-1 n-1 i n=[int(i) for i in input().split()] [int(i) for i in input().split()] n c=[int(i) for i in input().split()] [int(i) for i in input().split()] c dp=[[int(1e4) for i in range(m+1)] for j in range(n+1)] [[int(1e4) for i in range(m+1)] for j in range(n+1)] dp i-=1 1 i m,n=[int(i) for i in input().split()] [int(i) for i in input().split()] m
m,n=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
dp=[[int(1e4) for i in range(m+1)] for j in range(n+1)]
i=n-1
while i>=0:
    for j in range(m+1):
        if j==c[i]:
            dp[i][j]=1
        elif j<c[i]:
            dp[i][j]=dp[i+1][j]
        else:
            dp[i][j]=min(dp[i+1][j],dp[i+1][j-c[i]]+1,dp[i][j-c[i]]+1)
    i-=1
print(dp[0][m])