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

#dp[i][j]をi番目まででj支払える最小枚数
dp = [[float("inf")] * (n+1) for _ in range(m+1)]

for _ in range(m+1):
    dp[_][0] = 0

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

#dp[i][j]をi番目まででj支払える最小枚数
dp = [[float("inf")] * (n+1) for _ in range(m+1)]

for _ in range(m+1):
    dp[_][0] = 0

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

