n, x = map(int, input().split())
a = sorted(map(int, input().split()))
if sum(a) == x:
    print(n)
    exit()
elif sum(a) < x:
    print(n - 1)
    exit()

y = x
ans = 0
for ai in a:
    if y - ai >= 0:
        y -= ai
        ans += 1
if y:
    b = a[:ans]
    sb = sum(b)
    for bi in b:
        for ai in a[ans:]:
            if sb - bi + ai == x:
                print(ans)
                exit()
    print(max(0, ans - 1))
else:
    print(ans)