# -*- coding: utf-8 -*- def main(): box_width = int(input()) block_num = int(input()) block_widths = sorted(list(map(int, input().split()))) total_width = 0 count = 0 for width in block_widths: total_width = total_width + width if box_width <= total_width: break count = count + 1 print(str(count) + "\n") if __name__ == '__main__': main()