t = int(input()) n = int(input()) a = [int(input()) for _ in range(n)] v = set() for r in range(n): dp = [-1]*(t+1) dp[0] = 0 for i in range(n): if i in v: continue for j in range(a[i], t+1)[::-1]: if dp[j]<0 and dp[j-a[i]]>=0: dp[j] = i for i in range(t+1)[::-1]: if dp[i] >= 0: break while i > 0: v.add(dp[i]) i -= a[dp[i]] if len(v) == n: break print(r+1)