include
include
include
using namespace std;
#define int long long
const int maxn=1e5+10;
int n,t;
struct node{
int x,y,z;
}e[maxn];
bool check(int i,int mid){
return (e[i].x+e[i].y)mid+e[i].z*mid(mid-1)/2>=t;
}
signed main(){
cin>>n>>t;
int ans=0;
for(int i=0;i<n;i++)
cin>>e[i].x>>e[i].y>>e[i].z;
for(int i=0;i<n;i++){
if(!e[i].y&&!e[i].z)continue;
int l=0,r=1e8,temp=0;
while(l<=r){
int mid=(l+r)/2;
if(check(i,mid))r=mid-1;
else temp=mid,l=mid+1;
}
ans+=e[i].ytemp+(temp-1)temp/2e[i].z;
int lv=t-(e[i].x+e[i].y)temp-(temp-1)temp/2e[i].z;
ans+=max(0ll,lv-e[i].x);
}
cout<<ans<<endl;
return 0;
}