# -*- coding: utf-8 -*-


#----------
n,x = list(map(int, input().rstrip().split()))
a_list = list(map(int, input().rstrip().split()))
#----------
a_list.sort()

x_remain=x
result = -1
for i in range(n):
    x_remain -= a_list[i]
    
    if x_remain < 0:
       result = i
       break

if result == -1 :
    result = n

print(result)
