# -*- coding: utf-8 -*-
"""
Created on Sat Sep 15 23:36:39 2018

@author: Yuki
"""

N, x = map(int, input().split())
A = [int(i) for i in input().split()]

A = sorted(A)
res = 0
for a in A:
    x -= a
    if x <= 0:
        break
    else:
        res += 1
if x != 0:
    print(max(res-1, 0))
else:
    print(res)

