n, m = map(int, input().split())
c_ls = [int(c) for c in input().split()]

c_ls.sort()

ct = 0
for c in c_ls:
    if c > m:
        break
    m -= c
    ct += 1

print(ct)