T1(100pts)

# include<iostream>
using namespace std;
# define ll long long

const int N=102;
int n;
ll p,z[N],a[N],b[N],sum;
ll l,r,mid,ans;

ll f(int i,ll x){
	if(x<=z[i]) return a[i]*x;
	else return a[i]*z[i]+b[i]*(x-z[i]);
}

bool check(ll x){
	sum=0;
	for(int i=1;i<=n;++i) sum+=f(i,x);
	return sum>=p;
}

int main(){
	cin>>n>>p;
	for(int i=1;i<=n;++i)
		cin>>z[i]>>a[i]>>b[i];
	l=1,r=p;
	while(l<=r){
		mid=(l+r)/2;
		if(check(mid)){
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	cout<<ans;
	return 0;
}