c = input() n = input() a = map(int, raw_input().split()) dp = [c+1]*(c+1) dp[0] = 0 ans = c+1 for e in a: for j in xrange(e, c+1): dp[j] = min(dp[j], dp[j-e]+1) ans = min(ans, dp[c]) print-(ans>c)or ans