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 w: L -= min(w) w.remove(min(w)) if L > 0: count += 1 else: break print(count) if __name__ == "__main__": test()