a = int(input()) b = int(input()) C = sorted(map(int, input().split())) d = 0 ans = 0 for x in C: d += x ans += 1 if d >= a: break print(ans)