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

a_list = [int(v) for v in input().split()]
a_list.sort()

person = 0

break_flag = False

for a in a_list[:-1]:
    if a <= x:
        x -= a
        person += 1
    else:
        break_flag=True
        break
  
if not break_flag:
    if x == a_list[-1]:
        person += 1
