# encoding: utf-8
# N = int(input())
# S = input()
# N, M = map(int, input().split())
# A = list(map(int, input().split()))

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

def recsearch(i, x_tmp):
    # print("#", i, x_tmp)
    if i == N:
        if x_tmp > 0: ret = -1
        else: ret = 0
    elif x_tmp < A[i]: ret = recsearch(i + 1, x_tmp)
    else: ret = max((recsearch(i + 1, x_tmp - A[i]) + 1, recsearch(i + 1, x_tmp)))
    return ret
        
print(max(0, recsearch(0, x)))