n,m=[int(i) for i in input().split(" ")]
c=sorted([int(i) for i in input().split(" ")])
c.pop(0)
table=[[0 for j in range(n+1)] for i in range(m)]
for j in range(n+1):
    table[0][j]=j
for i in range(1,m):
    for j in range(n+1):
        if j>=c[i-1]:
            table[i][j]=min(table[i-1][j],table[i-1][j-c[i-1]]+1,table[i][j-c[i-1]]+1)
        else:
            table[i][j]=table[i-1][j]

print(table[-1][-1])
 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 n,m=[int(i) for i in input().split(" ")] n [int(i) for i in 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=sorted([int(i) for i in input().split(" ")]) c sorted([int(i) for i in input().split(" ")]) sorted [int(i) for i in input().split(" ")] c.pop(0) c.pop c pop 0 [0 for j in range(n+1)] for i in range(m) for i in range(m) i range(m) range m for i in range(m) [0 for j in range(n+1)] table=[[0 for j in range(n+1)] for i in range(m)] table [[0 for j in range(n+1)] for i in range(m)] for j in range(n+1):
    table[0][j]=j j range(n+1) range n+1 n 1 table[0][j]=j table[0][j] [0] table 0 j j for i in range(1,m):
    for j in range(n+1):
        if j>=c[i-1]:
            table[i][j]=min(table[i-1][j],table[i-1][j-c[i-1]]+1,table[i][j-c[i-1]]+1)
        else:
            table[i][j]=table[i-1][j] i range(1,m) range 1 m for j in range(n+1):
        if j>=c[i-1]:
            table[i][j]=min(table[i-1][j],table[i-1][j-c[i-1]]+1,table[i][j-c[i-1]]+1)
        else:
            table[i][j]=table[i-1][j] j range(n+1) range n+1 n 1 if j>=c[i-1]:
            table[i][j]=min(table[i-1][j],table[i-1][j-c[i-1]]+1,table[i][j-c[i-1]]+1)
        else:
            table[i][j]=table[i-1][j] j>=c[i-1] j c[i-1] c i-1 i 1 table[i][j]=min(table[i-1][j],table[i-1][j-c[i-1]]+1,table[i][j-c[i-1]]+1) table[i][j] [i] table i j min(table[i-1][j],table[i-1][j-c[i-1]]+1,table[i][j-c[i-1]]+1) min table[i-1][j] [i-1] table i-1 i 1 j table[i-1][j-c[i-1]]+1 table[i-1][j-c[i-1]] [i-1] table i-1 i 1 j-c[i-1] j c[i-1] c i-1 i 1 1 table[i][j-c[i-1]]+1 table[i][j-c[i-1]] [i] table i j-c[i-1] j c[i-1] c i-1 i 1 1 table[i][j]=table[i-1][j] table[i][j] [i] table i j table[i-1][j] [i-1] table i-1 i 1 j print(table[-1][-1]) print table[-1][-1] [-1] table -1 -1 m=[int(i) for i in input().split(" ")] [int(i) for i in input().split(" ")] m n,m=[int(i) for i in input().split(" ")] [int(i) for i in input().split(" ")] n c=sorted([int(i) for i in input().split(" ")]) sorted([int(i) for i in input().split(" ")]) c table=[[0 for j in range(n+1)] for i in range(m)] [[0 for j in range(n+1)] for i in range(m)] table
n,m=[int(i) for i in input().split(" ")]
c=sorted([int(i) for i in input().split(" ")])
c.pop(0)
table=[[0 for j in range(n+1)] for i in range(m)]
for j in range(n+1):
    table[0][j]=j
for i in range(1,m):
    for j in range(n+1):
        if j>=c[i-1]:
            table[i][j]=min(table[i-1][j],table[i-1][j-c[i-1]]+1,table[i][j-c[i-1]]+1)
        else:
            table[i][j]=table[i-1][j]

print(table[-1][-1])

