import numpy as np
import sys

input = sys.stdin.readline

N,x = map(int,input().split())

a = list(map(int,input().split()))

a.sort()

b = 0

if a[0] > x:
    print(0)
    exit()

for i in range(N-1):
    b += a[i]
    if b >= x:
        print(i+1)
        exit()

if (b+a[N-1]) == x:
    print(N)
else:
    print(N-1)

