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