N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
sum_ = 0 
ans = 0 
for i in range(N):
        sum_ += a[i]
        if sum_ > x:
                break
        ans += 1
print(ans)