import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N,M = map(int,readline().split()) A = np.array(read().split(),np.int64) A.sort() Acum = A.cumsum() answer = np.count_nonzero(Acum <= M) print(answer)