import sys input = sys.stdin.readline L = int(input()) N = int(input()) W = list(map(int, input().split())) dp = [0] * (L + 1) for w in W: for j in range(L, w - 1, -1): dp[j] = max(dp[j], dp[j - w] + 1) print(dp[L])