#pragma GCC optimize("O3,inline")
#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>, pair<int, int>>> vals;
vector<vector<long long>> mem;
int cnt = 0;
vector<long long> v, v1, lazy;
vector<int> lazys, r, l;
void build(int s, int e, int& n) {
n = cnt++;
v[n] = v1[n] = lazy[n] = lazys[n] = 0;
if (s == e) return;
int m = (s + e) >> 1LL;
build(s, m, l[n]);
build(m + 1, e, r[n]);
}
void prop(int s, int e, int n) {
if (s == e) return;
if (lazys[n]) {
v1[l[n]] = v1[r[n]] = 1e15;
lazys[l[n]] = lazys[r[n]] = 1;
v[l[n]] = v[r[n]] = lazy[l[n]] = lazy[r[n]] = 0;
lazys[n] = 0;
}
if (lazy[n] == 0) return;
v[l[n]] += lazy[n];
v[r[n]] += lazy[n];
v1[l[n]] += lazy[n];
v1[r[n]] += lazy[n];
lazy[l[n]] += lazy[n];
lazy[r[n]] += lazy[n];
lazy[n] = 0;
}
void upd(int s, int e, int a, int b, long long x, int n) {
if (b < s || a > e) return;
if (a <= s && b >= e) {
v[n] += x;
v1[n] += x;
lazy[n] += x;
return;
}
prop(s, e, n);
int m = (s + e) >> 1LL;
upd(s, m, a, b, x, l[n]);
upd(m + 1, e, a, b, x, r[n]);
v[n] = min(v[l[n]], v[r[n]]);
v1[n] = min(v1[l[n]], v1[r[n]]);
}
void upds(int s, int e, int _n, long long x, int n) {
if (s == e) {
v1[n] = min(v1[n], x);
return;
}
prop(s, e, n);
int m = (s + e) >> 1LL;
if (_n <= m) upds(s, m, _n, x, l[n]);
else upds(m + 1, e, _n, x, r[n]);
v1[n] = min(v1[l[n]], v1[r[n]]);
}
long long qry(int s, int e, int a, int b, int n) {
if (a < 0) return 0;
if (b < s || a > e) return 1e15;
if (a <= s && b >= e) return v[n];
prop(s, e, n);
int m = (s + e) >> 1LL;
return min(qry(s, m, a, b, l[n]), qry(m + 1, e, a, b, r[n]));
}
long long qry1(int s, int e, int a, int b, int n) {
if(a < 0) return 0;
if (b < s || a > e) return 1e15;
if (a <= s && b >= e) return v1[n];
prop(s, e, n);
int m = (s + e) >> 1LL;
return min(qry1(s, m, a, b, l[n]), qry1(m + 1, e, a, b, r[n]));
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int N, M, K, a, b, c; cin >> N >> M >> K;
vector<pair<int, int>> vals1;
for (int i = 0; i < M; i++) {
cin >> a >> b >> c; a--, b--;
vals.push_back({ {b, a}, {c, i} });
vals1.push_back({ a, i });
}
sort(vals.begin(), vals.end());
for (int i = 0; i < M; i++) vals1[vals[i].second.second].second = i;
sort(vals1.begin(), vals1.end());
mem.resize(M, vector<long long>(K, -1));
v.resize(N * 2 + 5, -1);
v1.resize(N * 2 + 5, -1);
r.resize(N * 2 + 5, -1);
l.resize(N * 2 + 5, -1);
lazy.resize(N * 2 + 5, -1);
lazys.resize(N * 2 + 5, -1);
build(0, N, a);
for (int j = 0; j < K; j++) {
lazys[0] = 1;
v1[0] = 1e15;
v[0] = lazy[0] = 0;
upds(0, N, N, 0, 0);
int idx1 = M - 1, idx2 = M - 1;
while (idx2 >= 0) {
//cout << idx1 << ' ' << idx2 << '\n';
//for (int i = 0; i <= N; i++) cout << root->qry(i, i) << ' ';
//cout << '\n';
//for (int i = 0; i <= N; i++) cout << root->qry1(i, i) << ' ';
//cout << "\n\n";
if (vals1[idx1].first < vals[idx2].first.first) {
mem[idx2][j] = qry1(0, N, vals[idx2].first.first + 1, N, 0);
idx2--;
}
else {
upd(0, N, vals[vals1[idx1].second].first.first + 1, N, vals[vals1[idx1].second].second.first, 0);
if (j) upds(0, N, vals[vals1[idx1].second].first.first, qry(0, N, vals[vals1[idx1].second].first.first, vals[vals1[idx1].second].first.first, 0) + mem[vals1[idx1].second][j - 1], 0);
idx1--;
}
}
}
long long crnts = 0, ans = 1e15;
for (int i = 0; i < M; i++) {
ans = min(ans, crnts + mem[i][K - 1]);
crnts += vals[i].second.first;
}
ans = min(ans, crnts);
cout << ans << '\n';
}