import pandas as pd import numpy as np def test(): L = int(input()) N = int(input()) w = list(map(int,input().split())) count = 0 while True: L -= min(w) w.remove(min(w)) if L < 0: break else: count += 1 print(count) if __name__ == "__main__": test()