# encoding: utf-8
# N = int(input())
# S = input()
# N, M = map(int, input().split())
# A = list(map(int, input().split()))

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

ans = 0
x_tmp = x
for i, Ai in enumerate(sorted(A)):
    x_tmp -= Ai
    if x_tmp >= 0: ans += 1
    else: break

if sum(A) == x: print(N)
elif x_tmp + Ai == 0: print(max(0, ans))
else: print(max(0, ans - 1))