import sys
N, x = map(int, sys.stdin.readline().rstrip().split())
aa = sorted(list(map(int, sys.stdin.readline().rstrip().split())))
cnt = 0
for a in aa:
    if a == aa[-1]:
        if a == x:
            cnt += 1
    else:
        if a <= x:
            cnt += 1
            x -= a
        else:
            break
print(cnt)
