# -*- coding: utf-8 -*- def main(): l = int(input()) n = int(input()) ws = sorted(map(int, input().split())) # 最悪 while l < sum(ws): ws.pop() print(len(ws)) if __name__ == '__main__': main()