import numpy as np

N, x = map(int, input().split())
a = input().split()

a = np.array(a, int)

a = np.sort(a)

count = 0
for  i in range(N):
    if x > 0:
        x = x - a[i]
        if x >= 0:
             count += 1
    else:
        break
print(count)