#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int M = 205;
long long n, m, k, cnt, ans;
long long g[N], h[N], dp[N][M];
struct redpocket {
  long long s, t, d, w;
  bool operator<(const redpocket &x) const {
    if (w == x.w) return d < x.d;
    return w < x.w;
  }
} a[N];
priority_queue<redpocket> q;
bool cmp(redpocket x, redpocket y) { return x.s < y.s; }
signed main() {
  scanf("%lld %lld %lld", &n, &m, &k);
  for (long long i = 1; i <= k; i++)
    scanf("%lld %lld %lld %lld", &a[i].s, &a[i].t, &a[i].d, &a[i].w);
  sort(a + 1, a + k + 1, cmp);
  g[0] = 1;
  cnt = 1;
  for (long long i = 1; i <= n; i++) {
    while (i >= a[cnt].s && cnt <= k) q.push(a[cnt++]);
    if (q.empty())
      g[i] = i + 1;
    else {
      if (q.top().t < i) {
        i--;
        q.pop();
        continue;
      }
      g[i] = q.top().d + 1;
      h[i] = q.top().w;
    }
  }
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0] = 0;
  for (long long i = 0; i <= n; i++) {
    for (long long j = 0; j <= m; j++) {
      dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]);
      dp[g[i]][j] = min(dp[g[i]][j], dp[i][j] + h[i]);
    }
  }
  ans = 0x3f3f3f3f3f3f3f3f;
  for (long long i = 0; i <= m; i++) ans = min(ans, dp[n + 1][i]);
  cout << ans;
  return 0;
}
