L = int(input()) input() e = list(map(int, input().split())) e.sort() i = 0 j = 0 while i < L: i = i + sum(e[0:j+1]) j = j + 1 else: print j