#include <iostream>
using namespace std;
#include <bits/stdc++.h>
int main() {
// your code goes here
int arr[]={1,2,3,4,5,6};
int n;
cin>>n;
int k;
cin>>k;
sort(arr,arr+n);
int i=0,j=n-1,sum=0,count=0;
for(i=0,j=n-1;i<n && j>=0;i++)
{
sum=arr[i]+arr[j];
while(sum>k && i!=j)
{
j--;
sum=arr[i]+arr[j];
}
if(i==j)
{
break;
}
count+=(j-i);
}
cout<<count;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KCmludCBtYWluKCkgewoJLy8geW91ciBjb2RlIGdvZXMgaGVyZQoJCglpbnQgYXJyW109ezEsMiwzLDQsNSw2fTsKCWludCBuOwoJY2luPj5uOwoJaW50IGs7CgljaW4+Pms7Cglzb3J0KGFycixhcnIrbik7CglpbnQgaT0wLGo9bi0xLHN1bT0wLGNvdW50PTA7Cglmb3IoaT0wLGo9bi0xO2k8biAmJiBqPj0wO2krKykKCSB7CgkgCXN1bT1hcnJbaV0rYXJyW2pdOwoJIAl3aGlsZShzdW0+ayAmJiBpIT1qKQoJIAkgewoJIAkgCWotLTsKCSAJIAlzdW09YXJyW2ldK2FycltqXTsKCSAJIH0KCSAJIGlmKGk9PWopCgkgCSAgewoJIAkgIAlicmVhazsKCSAJICB9CgkgCSAgCgkgCSAgY291bnQrPShqLWkpOwoJIH0KCSBjb3V0PDxjb3VudDsKCQoJcmV0dXJuIDA7Cn0=