#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,j,k) for (int i=j;i<=k;i++)
#define dep(i,j,k) for (int i=j;i>=k;i--)
#define M(a,b) memset(a,b,sizeof(a))
using namespace std;
int ans,n,m,k,w[50005];
struct node{
int u,v,c;
}e[50005];
bool cmp(node a,node b){
if(a.v!=b.v) return a.v<b.v;
return a.u<b.u;
}
int main(){
// freopen("bus.in","r",stdin);
// freopen("bus.out","w",stdout);
scanf("%d%d%d",&k,&n,&m);
rep(i,1,k) scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].c);
sort(e+1,e+1+k,cmp);
rep(i,1,k){
if(w[e[i].u]>=m) continue;
int minn=2e9;
rep(j,e[i].u,e[i].v){
minn=min(m-w[j],minn);
if(minn<=0) break;
}
if(minn>0){
if(minn>=e[i].c){
rep(j,e[i].u,e[i].v-1) w[j]+=e[i].c;
ans+=e[i].c;
}
else{
rep(j,e[i].u,e[i].v-1) w[j]+=minn;
ans+=minn;
}
}
}
printf("%d\n",ans);
return 0;
}