# -*- coding: utf-8 -*-
n,x = map(int, input().split())
a = sorted([int(x) for x in input().split()])

ret = 0
for i in range(n):
    if x-a[i]>=0:
        ret += 1
        x = x-a[i]
    else:
        break
if x>0:
    ret = max(0,ret-1)
print(ret)
