def test(): L = int(input()) N = int(input()) w = list(map(int,input().split())) count = 0 sorted(w) while w: L -= min(w) w.remove(min(w)) if L < 0: break count += 1 print(count) if __name__ == "__main__": test()