line = input().split()
N = int(line[0])
x = int(line[1])
ans = 0

a = sorted(input().split())
a = [int(i) for i in a]

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