#!/usr/bin/env python3

N, x = [int(x) for x in input().split(" ")]
A = sorted([int(x) for x in input().split(" ")])

ans = 0
for a in A:
    if x < a:
        break
    ans += 1
    x -= a

if x > 0 and ans > 0:
    ans -= 1

print(ans)
