#include<bits/stdc++.h>
const int maxn=2e5;
inline const void read(int &a)
{
a=0;
char c=getchar();
while(c<'0'||c>'9')c=getchar();
while(c>='0'&&c<='9')
{
a=(a<<1)+(a<<3)+c-'0';
c=getchar();
}
}
inline const void write(int a)
{
if(a>9)write(a/10);
putchar(a%10+'0');
}
int k,n,m,ans=0;
int start[maxn],end[maxn],num[maxn],next[maxn],point[maxn],bus[maxn];
class onbus
{
public:
int v,s,e,nex[maxn],prior[maxn];
inline const void clear()
{
s=0;v=0;e=0;
memset(nex,0,sizeof(nex));
memset(prior,0,sizeof(prior));
}
inline const void out(int k)
{
while(v)
{
if(end[s]<=k)
{
v-=bus[s];
ans+=bus[s];
s=nex[s];
if(!v)e=s;
prior[s]=0;
}
else return ;
}
}
inline const void push(int p)
{
int c=e,sum=0,load;
while(c&&end[c]>end[p])
{
sum+=bus[c];
c=prior[c];
}
load=std::min(m-(v-sum),num[p]);
if(load<=0)return ;
bus[p]=load;v+=load;
prior[nex[c]]=p;nex[p]=nex[c];
nex[c]=p;prior[p]=c;
if(!prior[p])s=p;if(!nex[p])e=p;
if(v>m)
{
int cut=v-m;
v=m;
while(cut)
{
if(bus[e]>cut){bus[e]-=cut;return ;}
else
{
cut-=bus[e];
e=prior[e];
nex[e]=0;
}
}
}
}
}on;
inline const void add(int i)
{
next[i]=point[start[i]];
point[start[i]]=i;
}
int main()
{
memset(bus,0,sizeof(bus));
memset(point,0,sizeof(point));
read(k);read(n);read(m);
for(int i=1;i<=k;i++){read(start[i]);read(end[i]);read(num[i]);add(i);}
on.clear();
for(int i=1;i<=n;i++)
{
int side=point[i];
on.out(i);
while(side)
{
on.push(side);
side=next[side];
}
}
write(ans);
return 0;
}