#coding:utf-8
n, x = map(int, input().split())
a = list(map(int, input().split()))
child = sorted(a)
ans = 0
candy = 0

for i in range(n):
    candy += child[i]
    if candy == x:
        print(i+1)
        exit()
    elif candy > x:
        print(0)
        exit()