#include <bits/stdc++.h>
using namespace std;
int n, s;
int arr[3000];
long long int sum = 0;
void f(int start, int ind, int tot) {
  if (ind != start && ind + 1 != n) f(start, ind + 1, tot);
  if (ind + 1 != n && tot + arr[ind] < s)
    f(start, ind + 1, tot + arr[ind]);
  else if (tot + arr[ind] == s) {
    sum += (start + 1) * (n - ind);
  }
}
int main() {
  cin >> n >> s;
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 0; i < n; i++) f(i, i, 0);
  cout << sum << endl;
}
