import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,num = IL()
a = IL()

a.sort()

cnt = 0
for i in range(N):
    if num-a[i] >= 0:
        num -= a[i]
        cnt += 1
    if num == 0:
        cnt += 1
        break

print(max(0,cnt-1))