# 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)
for a in A:
    if sumA > x:
        sumA -= a
        ans -= 1
    else:
        break
print(ans)
