def func(): weight = int(input()) num =int(input()) L = [int(i) for i in input().split()] L.sort() for i in range(len(L)): weight -= L[i] i += i if weight <= 0: break print(i) func()