l = int(input()) n = int(input()) W = sorted(list(map(int, input().split()))) ma = W[-1] m = ma * n + 1 dp = [-1] * m dp[0] = 0 for w in W: for i in range(m - 1, -1, -1): if dp[i] >= 0: dp[i + w] = max(dp[i] + 1, dp[i + w]) print(max(dp[:l - 1])) #print(dp[:l - 1])