#! /usr/bin/env python # -*- coding: utf-8 -*- import os import sys import itertools import math from collections import Counter, defaultdict class Main(object): def __init__(self): pass def solve(self): ''' insert your code ''' n, m = map(int, raw_input().split()) c = map(int, raw_input().split()) c.sort() tmp = m ans = 0 for i in range(len(c)): if tmp >= c[i]: ans += 1 tmp -= c[i] else: break print ans return None if __name__ == '__main__': m = Main() m.solve()