cost,m,=map(int,input().split())
c=list(map(int,input().split()))
DP=[[10**10 for i in range(60001)] for j in range(21)]
for i in range(m):
    DP[i][c[i]]=1
    for j in range(60001):
        if c[i]>j:
            if i==0:
                DP[i][j]=0
            else:DP[i][j]=DP[i-1][j]
        elif j+c[i]<=60000:
            DP[i][j]=min(DP[i][j-c[i]]+1,DP[i-1][j])
print(DP[m-1][cost]) cost,m,=map(int,input().split()) cost 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 [10**10 for i in range(60001)] for j in range(21) for j in range(21) j range(21) range 21 for j in range(21) [10**10 for i in range(60001)] DP=[[10**10 for i in range(60001)] for j in range(21)] DP [[10**10 for i in range(60001)] for j in range(21)] for i in range(m):
    DP[i][c[i]]=1
    for j in range(60001):
        if c[i]>j:
            if i==0:
                DP[i][j]=0
            else:DP[i][j]=DP[i-1][j]
        elif j+c[i]<=60000:
            DP[i][j]=min(DP[i][j-c[i]]+1,DP[i-1][j]) i range(m) range m DP[i][c[i]]=1 DP[i][c[i]] [i] DP i c[i] c i 1 for j in range(60001):
        if c[i]>j:
            if i==0:
                DP[i][j]=0
            else:DP[i][j]=DP[i-1][j]
        elif j+c[i]<=60000:
            DP[i][j]=min(DP[i][j-c[i]]+1,DP[i-1][j]) j range(60001) range 60001 if c[i]>j:
            if i==0:
                DP[i][j]=0
            else:DP[i][j]=DP[i-1][j]
        elif j+c[i]<=60000:
            DP[i][j]=min(DP[i][j-c[i]]+1,DP[i-1][j]) c[i]>j c[i] c i j if i==0:
                DP[i][j]=0
            else:DP[i][j]=DP[i-1][j]
         i==0 i 0 DP[i][j]=0 DP[i][j] [i] DP i j 0 elif j+c[i]<=60000:
            DP[i][j]=min(DP[i][j-c[i]]+1,DP[i-1][j]) j+c[i]<=60000 j+c[i] j c[i] c i 60000 DP[i][j]=min(DP[i][j-c[i]]+1,DP[i-1][j]) DP[i][j] [i] DP i j min(DP[i][j-c[i]]+1,DP[i-1][j]) min 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] [i-1] DP i-1 i 1 j print(DP[m-1][cost]) print DP[m-1][cost] [m-1] DP m-1 m 1 cost m,=map(int,input().split()) map(int,input().split()) m c=list(map(int,input().split())) list(map(int,input().split())) c cost,m,=map(int,input().split()) map(int,input().split()) cost DP=[[10**10 for i in range(60001)] for j in range(21)] [[10**10 for i in range(60001)] for j in range(21)] DP
cost,m,=map(int,input().split())
c=list(map(int,input().split()))
DP=[[10**10 for i in range(60001)] for j in range(21)]
for i in range(m):
    DP[i][c[i]]=1
    for j in range(60001):
        if c[i]>j:
            if i==0:
                DP[i][j]=0
            else:DP[i][j]=DP[i-1][j]
        elif j+c[i]<=60000:
            DP[i][j]=min(DP[i][j-c[i]]+1,DP[i-1][j])
print(DP[m-1][cost])
