n, x = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort()
ans = s = 0
for i, t in enumerate(a):
    if s > x:
        break
    for j in xrange(i, n):
        if s + a[j] == x:
            ans = i + 1
        if ans < i:
            ans = i
    s += t
print ans
