#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, x;
    cin >> n;
    cin >> x;
    int hai = 0;
    int alSum = 0;
    int arr[n][2];
    for (int i = 0; i < n; i++) {
        cin >> arr[i][0];
        cin >> arr[i][1];
    }
    
    for (int i = 0; i < n; i++) {
        hai++;
        alSum += arr[i][0] * arr[i][1];
        if(alSum > x * 100){
            cout << hai << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


void solve(){
    ll N,c;
    cin >> N >> c;
    vector<pll> v;
    ll a;
    vll cs(N+1);
    for(int i = 1; i <= N; i++){
        cin >> a;
        v.pb({a,i});
        cin >> a;
        v.pb({a+1,-i});
        cin >> cs[i];
    }
    sort(v.begin(),v.end());
    //cout << v[0].se<<"lol ";
    ll k =cs[v[0].se];
    ll l =v[0].fi;
    ll ans = 0;
    //cout << k <<" kek";
    for(int i = 1; i < 2*N; i++){
    //    cout << "k ans "<<k <<" "<<ans<<"\n";
        ans+=(v[i].fi-l)*min(c,k);
        l = v[i].fi;

        if(v[i].se<0)k-=cs[-v[i].se];
        else k+= cs[v[i].se];
    }
    cout << ans <<"\n";
    return;
}

int main(){
    int T = 1;
    //cin >> T;
    while(T--){
        solve();
    }
    return 0;
}
