def quick_sort(alist, first, last):
if first >= last:
return
mid_value = alist[first]
low = first
high = last
while low
while low = mid_value:
high -= 1
alist[low] = alist[high]
while low
low += 1
alist[high] = alist[low]
alist[low] = mid_value
# 对low左边的列表执行快速排序
quick_sort(alist, first, low - 1)
# 对low右边的列表执行快速排序
quick_sort(alist, low + 1, last)
if __name__ == "__main__":
n, p = map(int, input().strip().split())
# 将耗时少的蟠桃排在前面
time_consume = list(map(int, input().strip().split()))
quick_sort(time_consume, 0, n - 1)
# 模拟吃桃过程
count = 0
for i in range(n):
if n > 0 and p >= time_consume[i]:
p -= time_consume[i]
n -= 1
count += 1
else:
# 没时间或者没桃了
break
print(count)