from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007
INF = 122337203685477580

def solve():
    N,x = map(int, input().split())
    vec =list(map(int, input().split())) 
    vec.sort()
    cnt = 0
    index = 0
    while(x > 0 and index < N):
        if(x - vec[index] > 0):
            x -= vec[index]
            cnt += 1
        elif(x - vec[index] == 0):
            cnt += 1
            x -= vec[index]
        else:
            break
        index += 1
        # print(x)
    
    if(x >0):
        cnt -= 1
    if(index == 0):
        cnt = 0
    print(cnt)
if __name__ == '__main__':
    solve()
