#!/usr/bin/python
# -*- coding: utf-8 -*-

s = raw_input()
n, x =  [int(i) for i in s.split()]

aa = raw_input()
a = [int(i) for i in aa.split()]

a = sorted(a)
count = 0
total = 0
for i in a:
    total += i
    if total > x:
        break
    count += 1
print count