n, m = map(int, input().split())
c = [int(i) for i in input().split()]
inf = 10**10

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

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

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

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

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

print(dp[m][n])
