#!/usr/bin/env python

n, x = map(int, input().split())
a = list(map(int, input().split()))

a = sorted(a)
if x == sum(a):
    print(n)
    exit()
if x > sum(a):
    print(n-1)
    exit()
if x < min(a):
    print(0)
    exit()

ans = 0 
tmp = n 
while tmp >= 0:
    tmp -= a[ans]
    ans += 1

print(ans)
