#include <bits/stdc++.h>
using namespace std;
int main()
{
int m,p,ans=0,sum=0;
cin>>m>>p;
for(int i=0;i<m;++i){
int a,b,c;
cin>>a>>b>>c;
vector<int>v;
v.push_back(a);
v.push_back(b);
v.push_back(c);
sort(v.begin(),v.end());
if(v[2]-v[0]>=p){
ans++;
sum=sum+(a+b+c)/3;
}
}
cout<<ans<<" "<<sum;
return 0;
}