#include <iostream>
#include <fstream>
#include <cmath>

using namespace std;

int main()
{
   long long n,M,a[100000],num=0;
   ifstream fi("TONGBANGM.INP");
   fi>>n>>M;
   for (int i=0;i<n;i++){fi>>a[i];
   }
   fi.close();
   ofstream fo("TONGBANGM.OUT");
   for (int k=0;k<n;k++){
   	for (int g=k+1;g<n;g++){
   		for (int h=g+1;h<n;h++){if ((a[k]+a[g]+a[h])==M){num++;
		   }
		   }
	   }
   }
   
}
