import sys
input = sys.stdin.readline

def main():
    N, x = map(int, input().split())
    a_list = list(map(int, input().split()))
    if sum(a_list) == x:
      print(N)
      sys.exit()
    for i, a in enumerate(sorted(a_list), start=1):
        x -= a
        if x < 0:
            break
    if x >= 0:
        print(i)
    else:
        print(i-1)
