box_size = int(input()) box_cnt = int(input()) boxes = input() boxes = [int(b) for b in boxes.split()] boxes.sort() for i,x in enumerate(boxes): box_size -= x if box_size < 0: print(str(i)+"\n") found = True break if found == False: print(str(box_cnt)+"\n")