N, x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
use_list = []
for i in range(2**N):
    use_list.append(list(map(int, list(bin(i)[2::].zfill(N)))))
for u in use_list:
    s = 0
    
    for i in range(N):
        if u[i] == 1:
            s += a[i]
    if s < x:
        ans = max(ans, sum(u)-1)
    elif s == x:
        ans = max(ans, sum(u))
print(ans)