#include <bits/stdc++.h>
using namespace std;
inline unsigned long long max(unsigned long long x, unsigned long long y) {
  return x > y ? x : y;
}
inline unsigned long long min(unsigned long long x, unsigned long long y) {
  return x > y ? y : x;
}
inline unsigned long long read() {
  unsigned long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
const unsigned long long N = 1e5 + 10;
unsigned long long n, m, k, dp[N][205], g[N], h[N];
struct node {
  unsigned long long s, t, d, v;
  bool operator<(const node& x) const {
    if (v == x.v) return d < x.d;
    return x.v > v;
  }
} a[N];
inline bool cmp(node x, node y) { return x.s < y.s; }
priority_queue<node> q;
signed main() {
  n = read(), m = read(), k = read();
  for (unsigned long long i = 1; i <= k; i++)
    a[i].s = read(), a[i].t = read(), a[i].d = read(), a[i].v = read();
  sort(a + 1, a + 1 + k, cmp);
  unsigned long long pos = 1;
  g[0] = 1;
  for (unsigned long long i = 1; i <= n; i++) {
    while (pos <= k && a[pos].s <= i) q.push(a[pos++]);
    if (q.empty())
      g[i] = i + 1;
    else {
      node u = q.top();
      if (u.t < i) {
        --i;
        q.pop();
        continue;
      }
      g[i] = u.d + 1, h[i] = u.v;
    }
  }
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0] = 0;
  for (unsigned long long i = 0; i <= n; i++)
    for (unsigned long long j = 0; j <= m; j++)
      dp[i + 1][j + 1] = std::min(dp[i + 1][j + 1], dp[i][j]),
                    dp[g[i]][j] = std::min(dp[g[i]][j], dp[i][j] + h[i]);
  unsigned long long ans = 1e19;
  for (unsigned long long i = 0; i <= m; i++) ans = min(ans, dp[n + 1][i]);
  cout << ans;
}
