#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 int lowbit(int a)
{
return a&(-a);
}
int k,n,m,more[maxn],ans=0;
struct team
{
int start,end,num;
inline const bool operator<(const team&b)
{
if(end<b.end)return true;
else return false;
}
}t[maxn];
inline const void modify(int a,int b)
{
while(a<=n)
{
more[a]+=b;
a+=lowbit(a);
}
}
inline const int query(int a)
{
int ans=0;
while(a)
{
ans+=more[a];
a-=lowbit(a);
}
return ans;
}
int main()
{
memset(more,0,sizeof(more));
read(k);read(n);read(m);
for(int i=1;i<=k;i++){read(t[i].start);read(t[i].end);read(t[i].num);}
std::sort(t+1,t+1+k);
for(int i=1;i<=k;i++)
{
int load=std::min(m-query(t[i].start),t[i].num);
ans+=load;
modify(t[i].start,load);modify(t[i].end+1,-load);
}
std::cout<<ans;
return 0;
}