n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
candy = 0
if x <= a[0]:
    print(0)
    exit(0)
for i in range(n):
    candy += a[i]
    if candy >=x:
        print(i+1)
        exit(0)
if i == n-1:
    print(n-1)