N, x = map(int, input().split())
a = [int(i) for i in input().split()]
a = sorted(a)

sum_okashi = 0
ans = 0
for i in range(len(a)):
    sum_okashi += a[i]
    if sum_okashi > x:
        break
ans = i if sum_okashi > x else i + 1

print(ans)