N, x = tuple(int(i) for i in input().split())
a = [int(i) for i in input().split()]

def f(a, x):
    print("f", a, x)
    if not a:
        return 0

    a.append(x)
    a = sorted(a)
    i = a.index(x)
    print("i", a, i)
    if i < len(a)-1:
        return len(a) - 2
    elif a[i-1] == a[i]:
        return len(a) - 2
    return f(a[:i-1], x-a[i-1])


s = sum(a)
if x == s:
    print(N)
elif x > s:
    print(N-1)
else:
    print(f(a, s-x))
