n,m = map(int,input().split()) C = sorted(list(map(int,input().split()))) ret = 0 c = 0 for i in range(n): if ret + C[i] <= m: c += 1 ret += C[i] else: break print(c)