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)
sum = 0
for i in range(N):
  sum_candy += a[i]
  if sum_candy > x:
    break
print(i)

