n, m = map(int, input().split()) clst = list(map(int, input().split())) clst.sort() ans = 0 for c in clst: m -= c if m < 0: break ans += 1 print(ans)