import math
n, x = list(map(int, input().split()))
array = list(map(int, input().strip().split()))
array.sort()
ans = 0
for i in array:
    x = x-i
    if x < 0:
        break
    ans += 1
    
print(ans)