n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()

ans = 0
if a[0] > x:
    print(0)
else:
    for i in range(n):
        if a[i] <= x:
            x -= a[i]
            ans += 1
    if x == 0:
        print(ans)
    else:
        print(ans-1)