#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int M=1<<18;
const int N=1e5+10;
pair<ll,int> s[M];
ll lz[M];
int n;
vector<pair<int,ll>> f[N];
void build(int l,int r,int idx){
lz[idx]=0;
s[idx]={1e18,0};
if(l==r) return;
int m=(l+r)/2;
build(l,m,idx*2);
build(m+1,r,idx*2+1);
}
void pushlz(int l,int r,int idx){
if(!lz[idx]) return;
s[idx].first+=lz[idx];
s[idx].first=min(s[idx].first,(ll)1e18);
if(l!=r) lz[idx*2]+=lz[idx],lz[idx*2+1]+=lz[idx];
lz[idx]=0;
}
void upds(int l,int r,int idx,int a,pair<ll,int> b){
pushlz(l,r,idx);
if(a<l || a>r) return;
if(l==r){
pushlz(l,r,idx);
s[idx]=b;
return;
}
int m=(l+r)/2;
upds(l,m,idx*2,a,b);
upds(m+1,r,idx*2+1,a,b);
s[idx]=min(s[idx*2],s[idx*2+1]);
}
void update(int l,int r,int idx,int a,int b,ll val){
pushlz(l,r,idx);
if(a>r || b<l) return;
if(a<=l && b>=r){
lz[idx]+=val;
pushlz(l,r,idx);
return;
}
int m=(l+r)/2;
update(l,m,idx*2,a,b,val);
update(m+1,r,idx*2+1,a,b,val);
s[idx]=min(s[idx*2],s[idx*2+1]);
}
pair<ll,int> query(int l,int r,int idx,int a,int b){
pushlz(l,r,idx);
if(a>r || b<l) return {LLONG_MAX,0};
if(a<=l && b>=r) return s[idx];
int m=(l+r)/2;
return min(query(l,m,idx*2,a,b),query(m+1,r,idx*2+1,a,b));
}
pair<ll,int> cal(ll mid){
build(0,n,1);
upds(0,n,1,0,{0,0});
for(int i=1;i<=n;i++){
pair<ll,int> use=query(0,n,1,0,n);
use.second--;
use.first+=mid;
upds(0,n,1,i,use);
for(auto [l,cost]:f[i]){
update(0,n,1,0,l,cost);
}
}
// cout<<mid <<"\n";
// for(int i=0;i<=n;i++) cout<<query(0,n,1,i,i).first <<" ";
// cout<<"\n";
pair<ll,int> ret=query(0,n,1,0,n);
ret.second=-ret.second;
return ret;
}
int main(){
int m,k; cin>>n >>m >>k;
for(int i=1;i<=m;i++){
int s,t; ll c; cin>>s >>t >>c;
f[t].push_back({s,c});
}
ll l=0,r=1e14;
while(l<r){
ll mid=(l+r+1LL)/2LL;
pair<ll,int> tmp=cal(mid);
if(tmp.second>=k) l=mid;
else r=mid-1LL;
}
pair<ll,int> opt=cal(l);
//cout<<l <<" " <<opt.first <<" " <<opt.second <<"\n";
ll ret=opt.first-(ll)opt.second*l+(ll)(opt.second-k)*l;
cout<<ret;
}