a = int(input()) b = int(input()) C = sorted(map(int, input().split())) d = 0 ans = 0 # ループに入る前に「すでに目標達成しているか」をチェック if d >= a: print(0) else: for x in C: d += x ans += 1 if d >= a: break print(ans)