#include <bits/stdc++.h>
using namespace std;
const int maxi = 1e5 + 7;
const int maxj = 200 + 7;
struct Pkt {
  int s, t, d, w;
  bool operator<(const Pkt &b) const {
    if (w != b.w) return w < b.w;
    return d < b.d;
  }
} p[maxi];
bool cmp(Pkt a, Pkt b) { return a.s < b.s; }
priority_queue<Pkt> q;
;
long long dp[maxi][maxj];
int n, m, k;
long long min(long long a, long long b) { return a < b ? a : b; }
long long max(long long a, long long b) { return a > b ? a : b; }
int read() {
  int s = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    s = (s << 3) + (s << 1) + (ch ^ 48);
    ch = getchar();
  }
  return s;
}
int main() {
  memset(dp, 1, sizeof(dp));
  n = read();
  m = read();
  k = read();
  for (int i = 1; i <= k; ++i) {
    p[i].s = read();
    p[i].t = read();
    p[i].d = read() + 1;
    p[i].w = read();
  }
  sort(p + 1, p + k + 1, cmp);
  for (int i = 0; i <= m; ++i) dp[p[1].s][i] = 0;
  int cnt = 1;
  for (int i = p[1].s; i <= n; ++i) {
    while (!q.empty() && q.top().t < i) q.pop();
    while (p[cnt].s == i) {
      q.push((Pkt){p[cnt].s, p[cnt].t, p[cnt].d, p[cnt++].w});
    }
    if (q.empty()) {
      for (int j = 0; j <= m; ++j) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
    } else {
      for (int j = 0; j <= m; ++j)
        dp[q.top().d][j] = min(dp[q.top().d][j], dp[i][j] + q.top().w);
      for (int j = 0; j < m; ++j)
        dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]);
    }
  }
  long long ans = 1e18;
  for (int i = 0; i <= m; ++i) ans = min(ans, dp[n + 1][i]);
  printf("%lld\n", ans);
  return 0;
}
