from sys import stdin
import itertools
#stdin = open("input.txt")

if __name__ == "__main__":
    N, K = [int(item) for item in stdin.readline().split()]
    li = [int(item) for item in stdin.readline().split()]
    
    li.sort()
    a = [item for i, item in enumerate(itertools.accumulate(li)) if item <= K]
    print(len(a))