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

sum = 0;
for i in range(n):
    if sum+a[i] > x:
        break;
    else:
        sum = sum + a[i]

print(i)
        


