#!/usr/bin/env python #coding:utf8 def read(): N, M = map(int, raw_input().split()) cList = map(int, raw_input().split()) return M, cList def work((M, cList)): ans = 0 for C in sorted(cList): if C <= M: M -= C ans += 1 else: break print ans if __name__ == "__main__": work(read())