#1行目 width = input() #2行目 blocknum = input() split_blocknum=blocknum.split() #3行目 blocksize = input() split_blocksize=blocksize.split() blocksize_list = sorted(split_blocksize) for n in blocksize_list: if sum_blocksize + n <= width: sum_blocksize += n inblock += 1 else: break print(inblock)