L = input() input() e = 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