# -*- coding: utf-8 -*- def main(): L = int(input()) N = int(input()) numbers = [int(box) for box in input().split()] numbers.sort() La = L num = 0 for i in numbers: La = La - i if La > 0: num = num + 1 print(num) if __name__ == "__main__": main()