#!/usr/bin/python3
import copy

(n, s) = map(int, input().split())

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

# s => comb
itbl = {}
rtbl = {}

for i in range(n):
    ai = a[i]
    
    #itbl
    nitbl = copy.copy(itbl)
    if ai in nitbl:
        nitbl[ai] += i + 1
    else:
        nitbl[ai] = i + 1

    for sk in itbl:
        if sk + ai in nitbl:
            nitbl[sk + ai] += itbl[sk]
        else:
            nitbl[sk + ai] = itbl[sk]

    #rtbl
    if ai in rtbl:
        rtbl[ai] += (i + 1) * (n - i)
    else:
        rtbl[ai] = (i + 1) * (n - i)

    for sk in itbl:
        if sk + ai in rtbl:
            rtbl[sk + ai] += itbl[sk] * (n - i)
        else:
            rtbl[sk + ai] = itbl[sk] * (n - i)
            
    itbl = nitbl
    
print(rtbl.get(s, 0))
