#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=(1e5)+10;
int n,x; ll s[maxn],S;
struct node {
	int l,r,a; ll t;
	void init() {
		read(a); read(l); read(r);
		t=(ll)a*l+(ll)(x-a)*r;
		S-=(ll)l*a;
	}
} d[maxn];
bool cmp(node A,node B) {
	return A.t>B.t;
}
bool solve(ll mid) {
	ll q=mid/x,r=mid-q*x,tmp;
	if (q==n) return 1;
	for (int i=1;i<=n;i++) {
		tmp=S;
		if (i<=q) tmp+=s[q+1]-d[i].t;
		else tmp+=s[q];
		if (r>=d[i].a) tmp+=(ll)d[i].l*d[i].a+(r-d[i].a)*d[i].r;
		else tmp+=r*d[i].l;
		if (tmp>=0) return 1;
	} return 0;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(x);
	for (int i=1;i<=n;i++) d[i].init();
	sort(d+1,d+n+1,cmp);
	for (int i=1;i<=n;i++) s[i]=s[i-1]+d[i].t;
	ll l=0,r=(ll)x*n,mid,res;
	while (l<=r) {
		mid=(l+r)/2;
		if (solve(mid)) r=mid-1,res=mid;
		else l=mid+1;
	}
	printf("%lld\n",res);
	return 0;
}
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;

int main(){
    int d; cin >> d;
    ll g; cin >> g;
    vector<ll> p(d);
    vector<ll> c(d);
    rep(i, d) cin >> p[d - 1 - i] >> c[d - 1 - i];

    int min_count = 100000000;
    int count, sum;
    bool flag;
    for(int bit = 0; bit < (1 << d); bit++){
        flag = false;
        count = 0; 
        sum = 0;
        for(int i = 0; i < d; i++){
            if(bit & (1 << i)){
                int num;
                if((g - sum) > (d - i) * 100 * p[i] + c[i]){
                    sum += (d - i) * 100 * p[i] + c[i];
                    count += p[i];
                }else{
                    num = min(((g - sum) + ((d - i) * 100) - 1) / ((d - i) * 100), p[i]);
                    count += num;
                    flag = true;
                }
            }
            if(flag) break;
        }
        //cout << count << endl;
        if(flag) min_count = min(count, min_count);
    }
    cout << min_count << endl;
}