L = int(input()) N = int(input()) width_list = input() sum_width = 0 count = 0 min = 10000 for j in range(1, N): for i in width_list.split(): if min > i: min = i if sum_width + min > L: break else: sum_width += min print(j)