#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
using P = pair<long long,long long>;
using ll = long long;

int main() {
    ll N,W;
    cin >> N >> W;

    int p[N];
    vector<tuple<int,int,int>> vec(N);

    rep(i,N) cin >> get<0>(vec.at(i)) >> get<1>(vec.at(i)) >> get<2>(vec.at(i)) ;

    sort(vec.begin(),vec.end());
    vector<P> vec2(2*N);
    rep(i,N){
        vec2.at(i).first = get<0>(vec.at(i));
        vec2.at(i).second = get<2>(vec.at(i));
    }
    rep(i,N){
        vec2.at(N+i).first = get<1>(vec.at(i));
        vec2.at(N+i).second = -get<2>(vec.at(i));
    }

    sort(vec2.begin(),vec2.end());

    ll now = 0;
    bool over = false;
    int time=0;
    int before_time=0;
    rep(i,2*N){
        time = vec2.at(i).first;
        if ((before_time|=time)&&(now > W)){
            over = true;
        }
        now += vec2.at(i).second;
        before_time = time;
    }

    if(over){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}
// AtCoder template
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,m; cin >> n >> m;
    vector<ll> h(n); rep(i,n) cin >> h[i];
    vector<ll> w(m); rep(i,m) cin >> w[i];
    sort(h.begin(), h.end());
    sort(w.begin(), w.end());

    if(n == 1){
        ll ans = 1e17;
        rep(i,m) ans = min(ans, abs(h[0]-w[i]));
        cout << ans << endl;
        return 0;
    }


    vector<ll> ev(n/2+10,0LL), od(n/2+10,0LL);
    rep(i,n/2){
        ev[i+1] = ev[i] + h[2*i+1] - h[2*i];
        od[i+1] = od[i] + h[2*i+2] - h[2*i+1];
    }

    ll ans = 1e17;
    rep(i,m){

        int j = upper_bound(h.begin(), h.end(), w[i]) - h.begin();
        --j;

        if(j >= n-1){
            ans = min(ans, ev[n/2] + abs(w[i] - h[n-1]));
            continue;
        }

        if(j%2){            
            ans = min(ans, od[n/2]-od[(j+1)/2] + ev[(j+1)/2] + abs(h[j+1] - w[i]));
        }else{
            ans = min(ans, ev[j/2] + od[n/2] - od[j/2] + abs(w[i] - h[j]));
        }
    }

    cout << ans << endl;

}