n, m = map(int, input().split()) c = sorted([int(i) for i in input().split()]) e = 0 for idx in range(n): m = m - c[idx] if m >= 0: e += 1 print(e)