#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 7;
struct Seg {
  long long pos;
  bool open;
  long long id;
};
bool operator<(Seg a, Seg b) {
  if (a.pos != b.pos) {
    return a.pos < b.pos;
  }
  return a.open > b.open;
}
struct Smth {
  long long w, d, id;
};
bool operator<(Smth a, Smth b) {
  if (a.w != b.w) {
    return a.w > b.w;
  }
  if (a.d != b.d) {
    return a.d > b.d;
  }
  return a.id < b.id;
}
void solve() {
  long long n, m, k;
  cin >> n >> m >> k;
  vector<vector<long long> > dp(n + 2, vector<long long>(m + 1, INF));
  dp[1][0] = 0;
  long long s[k], t[k], d[k], w[k];
  vector<Seg> segs;
  for (long long i = 0; i < k; i++) {
    cin >> s[i] >> t[i] >> d[i] >> w[i];
    segs.push_back({s[i], true, i});
    segs.push_back({t[i] + 1, false, i});
  }
  sort(segs.begin(), segs.end());
  long long pos = 1;
  vector<long long> val(n + 1, -1);
  set<Smth> q;
  for (auto t : segs) {
    while (pos < t.pos) {
      if (!q.size()) {
        val[pos] = -1;
      } else {
        val[pos] = q.begin()->id;
      }
      pos++;
    }
    long long id = t.id;
    if (t.open) {
      q.insert({w[id], d[id], id});
    } else {
      q.erase({w[id], d[id], id});
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j <= m; j++) {
      long long pos = val[i];
      long long dn, wn;
      if (pos != -1) {
        dn = d[pos] + 1;
        wn = w[pos];
      } else {
        dn = i + 1, wn = 0;
      }
      dp[dn][j] = min(dp[dn][j], dp[i][j] + wn);
      if (j != m) {
        dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]);
      }
    }
  }
  long long res = INF;
  for (long long i = 0; i <= m; i++) {
    res = min(res, dp[n + 1][i]);
  }
  cout << res << "\n";
}
const long long TESTS = 1;
int main() {
  for (long long i = 0; i < TESTS; i++) {
    solve();
  }
}
