l=int(input()) n=int(input()) w=[*map(int,input().split())] d=[0]*-~l for i in w: for j in range(l,i-1,-1): d[j]=max(d[j],d[j-i]+1) print(d[l])