# -*- coding: utf-8 -*-
N, x =  map(int, input().split(' '))
A = list(map(int, input().split(' ')))
A.sort()

def dfs(i, rest, ret):
    if i == N:
        return ret
    else:
        if A[i] <= rest:
            return max(dfs(i+1, rest - A[i], ret + 1), dfs(i+1, rest, ret))
        else:
            return ret

ans = dfs(0, x, 0)
print(ans)
