l = int(input()) n = int(input()) width = list(map(int, input().split())) def dp(i, w): if i == 0: return 1 if w > width[0] else 0 else: if w > width[i]: return max(1 + dp(i-1, w-width[i]), dp(i-1, w)) else: return dp(i-1, w) print(dp(n-1, l))