from itertools import accumulate
from bisect import bisect
 
n, x = map(int, input().split())
arr = list(map(int, input().split()))
 
arr.sort()
sum_arr = list(accumulate(arr))
 
idx = bisect(arr, x)
 
if idx == n and sum_arr[n - 1] != x:
    idx -= 1

print(idx)