# -*- coding: utf-8 -*-

n, x = map(int, input().split())
sa = input().split()
a = []

for s in sa:
    a.append(int(s))

a = sorted(a)

ans = 0
sum = 0
for i in a:
    sum += i
    if sum > x:
        break
    ans += 1

print(ans)
