# -*- coding: utf-8 -*-
import numpy as np
N, x = map(int, input().split())
a = input().split()
for i in range(len(a)):
    a[i] = int(a[i])

for i in range(N):
    idx = np.argmin(a[i:]) + i
    temp = a[i]
    a[i] = a[idx]
    a[idx] = temp

sum = 0
for i in range(N):
    sum += a[i]

sum2 = 0
if sum < x:
    ans = N - 1
else:
    if a[0] > x:
        ans = 0
    for i in range(N):
        sum2 += a[i]
        if sum2 == x:
            ans = i + 1
            
print(ans)
    