def max_blocks(L, N): N.sort() current_sum= 0 count= 0 for W in N: if current_sum + W <= L: current_sum += W count += 1 else: break return count def main(): L, N, W= [int for _ in range(3)] W = list(map(int, input().split())) result= max_blocks(L, N) print(result)