def max_blocks_in_box(widths, L): n = len(widths) dp = [0] * (L + 1) for w in widths: for j in range(L, w - 1, -1): dp[j] = max(dp[j], dp[j - w] + 1) return dp[L] L = int(input()) n = int(input()) widths = list(map(int, input().split())) result = max_blocks_in_box(widths, L) print(result)