#include <bits/stdc++.h>
using namespace std;
ifstream fin ("oite.in");
ofstream fout ("oite.out");
const int N = 1030, mod = 1000003;
int n, a[N], ans, m;
vector < tuple<int, int> > H[mod + 1];
void findHash(int val, int j)
{
if (val < 0)
return;
int key = val % mod;
for (int ind = H[key].size() - 1; ind >= 0; ind--)
{
int x = get<0>(H[key][ind]);
int k = get<1>(H[key][ind]);
if (k > j)
{
if (x == val)
ans++;
}
else
return;
}
}
int main()
{
fin >> n >> m;
for (int i = 1; i <= n; i++)
fin >> a[i];
for (int i = 1; i < n; i++)
for (int j = i + 1; j <= n; j++)
H[(a[i] + a[j]) % mod].push_back(make_tuple(a[i] + a[j], i));
for (int i = 1; i < n; i++)
for (int j = i + 1; j <= n; j++)
findHash(m - (a[i] + a[j]), j);
fout << ans;
return 0;
}