# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

A = sorted(A, reverse=True)

ans = N
sumA = sum(A)
if sumA == x:
    ans = N
else:
    ans = N-1
    for a in A[1:]:
        if sumA > x:
            sumA -= a
            ans -= 1
        else:
            break
print(ans)
