#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

N, x = map(int, raw_input().split())

a = map(int, raw_input().split())

a.sort()

ans = 0

for num in a:
    x -= num
    if x < 0:
        break
    ans += 1

if ans == N and x > 0:
    ans -= 1

print ans