# 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 Ai in sorted(A):
    x_tmp -= Ai
    if x_tmp > 0: ans += 1
    elif x_tmp == 0:
        ans += 1
        break
    else:
        if ans > 0: ans -= 1
        break

if x_tmp > 0: ans -= 1

print(ans)