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

c.sort(reverse = True)

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

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

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

c.sort(reverse = True)

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

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

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

print(dp[m][n])