#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s;
  cin >> n >> s;
  int a[n];
  for (int i = 0; i < (int)(n); ++i) cin >> a[i];
  long long cnt = 0, jcnt = 0;
  for (int i = 0; i < (int)(n); ++i) {
    map<int, int> mp;
    jcnt = 0;
    for (int j = i; j < n; ++j) {
      if (mp.count(s - a[j]) > 0) {
        jcnt += mp[s - a[j]];
      } else if (a[j] == s) {
        jcnt++;
      }
      if (j != i) {
        for (auto itr = mp.rbegin(); itr != mp.rend(); itr++) {
          mp[itr->first + a[j]]++;
        }
      }
      mp[a[j]]++;
      cnt += jcnt;
    }
  }
  cout << cnt;
}
