#yuki247 c=int(raw_input()) n=int(raw_input()) a=[0]+map(int,raw_input().split()) dp=[c+1]*(c+1) dp[0]=0 for i in xrange(1,n+1): for j in xrange(c+1): if j+a[i]<=c: dp[j+a[i]]=min(dp[j+a[i]],dp[j]+1) if dp[c]>=c+1: dp[c]=-1 print dp[c]