N, x = input().split()
N = int(N)
x = int(x)
al = [int(a) for a in input().split()]

al.sort()

used = 0
ans = 0
for a in al:
    if used+a > x:
        break
    used += a
    ans += 1

print(ans)
    
        
        
