#include <bits/stdc++.h>
using namespace std;
inline int read()
{
char ch=getchar();
int x=0;
while(!isdigit(ch))
ch=getchar();
while(isdigit(ch))
{
x=x*10+ch-'0';
ch=getchar();
}
return x;
}
int k,n,m,ans;
struct node
{
int x,y,c;
}e[20010];
struct tree
{
int l,r;
int maxn,lazy;
}a[80010];
inline void build(int x,int y,int i)
{
a[i].l=x,a[i].r=y;
if(x==y) return ;
int mid=(x+y)>>1;
build(x,mid,i<<1);
build(mid+1,y,i<<1|1);
}
inline void pushdown(int i)
{
if(a[i].lazy)
{
a[i<<1].lazy+=a[i].lazy;
a[i<<1|1].lazy+=a[i].lazy;
a[i<<1].maxn+=a[i].lazy;
a[i<<1|1].maxn+=a[i].lazy;
a[i].lazy=0;
}
}
inline void update(int x,int y,int val,int i)
{
if(a[i].r<x||y<a[i].l) return ;
if(x<=a[i].l&&a[i].r<=y)
{
a[i].lazy+=val;
a[i].maxn+=val;
return ;
}
pushdown(i);
update(x,y,val,i<<1);
update(x,y,val,i<<1|1);
a[i].maxn=max(a[i<<1].maxn,a[i<<1|1].maxn);
}
inline int query(int x,int y,int i)
{
if(a[i].r<x||y<a[i].l) return 0;
if(x<=a[i].l&&a[i].r<=y)
return a[i].maxn;
pushdown(i);
return max(query(x,y,i<<1),query(x,y,i<<1|1));
}
inline bool cmp(node b,node c)
{
if(b.y==c.y)
return b.x>c.x;
else
return b.y<c.y;
}
int main()
{
int i;
k=read(),n=read(),m=read();
for(i=1;i<=k;i++)
e[i].x=read(),e[i].y=read(),e[i].c=read();
sort(e+1,e+k+1,cmp);
build(1,n,1);
for(i=1;i<=k;i++)
{
int tmp=query(e[i].x,e[i].y,1),rec=0;
if(tmp==m)
continue;
if(tmp+e[i].c<=m)
rec=e[i].c;
else
rec=m-tmp;
ans+=rec;
update(e[i].x,e[i].y-1,rec,1);
}
cout<<ans;
return 0;
}