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

c.sort()

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

for ni in range(0,n+1):
    dp[0][ni]=ni

for mi in range(0,m-1):
    for ni in range(n+1):
        if c[mi+1]>ni:
            dp[mi+1][ni]=dp[mi][ni]
        else:
            dp[mi+1][ni]=min(dp[mi+1][ni-c[mi+1]]+1,dp[mi][ni])
#    print(dp[mi])

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

c.sort()

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

for ni in range(0,n+1):
    dp[0][ni]=ni

for mi in range(0,m-1):
    for ni in range(n+1):
        if c[mi+1]>ni:
            dp[mi+1][ni]=dp[mi][ni]
        else:
            dp[mi+1][ni]=min(dp[mi+1][ni-c[mi+1]]+1,dp[mi][ni])
#    print(dp[mi])

print(dp[m-1][n])            
