#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define MP make_pair
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N, M, p = 0;
	cin >> N >> M;
	vector<int> width, blue(M);
	int mw = N;
	FOR(i,0,M){
		cin >> blue.at(i);
	}
	sort(range(blue));
	FOR(i,0,M){
		int a = blue.at(i);
		if(a-p!=1){
			width.push_back(a - p - 1);
			mw = min(mw, a - p - 1);
		}
		p = a;
	}
	if(N!=p){
		width.push_back(N - p);
		mw = min(mw, N - p);
	}

	/*
	FOR(i,0,width.size()){
		cout << width.at(i) << " ";
	}
	cout << endl;
	cout << mw << endl;
	*/

	int sum = 0;
	FOR(i,0,width.size()){
		sum += ceil((ld)width.at(i) / mw);
	}

	cout << sum << endl;

	return 0;
}


#include <bits/stdc++.h>
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define REPS(i, ss, nn ) for(int i = ss ; i < (int) nn; i++)
#define REV(i, ss, nn ) for(int i = ss ; i >= nn; i--)
#define deb(x) std::cout << #x << " " << x << endl;
#define debl(x) std::cout << #x << " " << x << " ";
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
namespace std{
    template<class Fun>
    class y_combinator_result{
        Fun fun_;
        public:
            template<class T>
            explicit y_combinator_result(T &&fun) : fun_(std::forward<T>(fun)){}
            template<class ...Args>
            decltype(auto) operator()(Args&&...args){
                return fun_(std::ref(*this), std::forward<Args>(args)...);
            }
    };
    template<class Fun>
    decltype(auto) y_combinator(Fun && fun){
        return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
    }
};
template<typename T>
bool u_max(T& a, T b){
    if( a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
bool u_min(T& a, T b){
    if( a > b){
        a = b;
        return true;
    }
    return false;
}
// struct edge{
//     int to, from;
//     ll cost;
//     edge(){ edge(0,0);}
//     edge(int to_, ll cost_){ edge(0, -1, 0);}
//     edge(int to_, int from_, ll cost_) : to(to_), from(from_), cost(cost_){}
// };

template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}

void solve(){
    int n;
    read(n);
    ll subscription;
    read(subscription);
    map<ll, ll> mp;
    REP(i, n){
        ll a, b, c;
        read(a, b, c);
        mp[a] += c;
        mp[b+1] -= c;
    }
    ll pay = 0;
    ll cost = 0;
    ll last = 0;
    for(auto& [day, price] : mp){
        if(cost < subscription){
            pay += cost * (day - last);
        }else{
            pay += subscription * (day - last);
        }
        cost += price;
        // debl(day) debl(cost) deb(pay)
        last = day;
    }
    cout << pay << endl;
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/
    solve();
    return 0;
}

