box, n = (int(i) for i in input().split()) li = list(map(int, input().split())) li.sort() count = 0 for i in range(len(li)): n = n - li[i] if n >= 0: count += 1 elif n < 0: break print(count)