lines = [raw_input() for _ in range(3)] L = int(lines[0]) W_list = sorted(map(int,lines[2].split())) cnt = 0 for i in W_list: L -= i if L <= 0:break cnt += 1 print cnt