n, s = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
rp = [true, false].repeated_permutation(n).to_a
rp_selected = rp.select{|rpi|
  sum = 0
  rpi.each_with_index{|j,index| sum += a[index] if j }
  sum == s
}
if rp_selected == []
  p 0
  exit
end
p rp_selected.map{|rpi|
  leftest_true = rpi.index(true) + 1
  rightest_true = rpi.reverse.index(true) + 1
  leftest_true * rightest_true
}.inject(:+)
