N,M = map(int,raw_input().split()) C = sorted(map(int,raw_input().split())) S = 0 for i in xrange(N): S += C[i] if S > M: print i break else: print N