
N, V = list(map(int, input().split()))
C = list(map(int, input().split()))
assert len(C)==N

W = [1 for i in range(N)]
res = [0 for i in range(N)]
F = [0 for i in range(V+1)]

def pack01_lo(F, c, w):
    for v in range(c, V+1)[::-1]:
        F[v] = max(F[v], F[v-c]+w)

for i in range(N):
    lo = max(V-sum(C[i:]), C[i])
    pack01_lo(F, lo, W[i])

#s = sum(C)
#print(F)
print(F[-1])