# n, X = map(int, input().split())
# A = [int(x) for x in input().split()]
# A = sorted(A)

# def solve(a, x):
#     cnt = 0
#     for i in range(n):
#         for j in range(i,n):
#             if x >= a[j]:
#                 x -= a[j]
#                 cnt += 1
#     return cnt
    

# print(solve(A[::-1], X))


n, X = map(int, input().split())
A = [int(x) for x in input().split()]

A = sorted(A)

def solve(a, x, j):
    cnt = 0
    for i in range(j, n):
        if x >= a[i]:
            x -= a[i]
            cnt += 1
    if x == 0:
        return cnt
    else:
        return cnt - 1
    
res = 0
for i in range(n):
    res = max(res, solve(A, X, i))
    res = max(res, solve(A[::-1], X, i))
print(res)
