import numpy as np
tmp1 = list(map(int, input().split()))
N = tmp1[0]
x = tmp1[1]
a = np.array(list(map(int, input().split())))
a = np.sort(a)
count = 0
for i in range(N):
  if a[i] > x or x == 0:
    break
  x -= a[i]
  count += 1
print(count)

