#include <bits/stdc++.h>
using namespace std;
long long n, m, k, ans;
struct node {
  long long s, t, d, w;
} a[100005];
bool cmp(node a, node b) { return a.s < b.s; }
bool operator<(const node &x, const node &y) {
  if (x.w == y.w) return x.d < y.d;
  return x.w < y.w;
}
priority_queue<node> Q;
long long nxt[100005], val[100005], f[100005][211];
int 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);
  nxt[0] = 1;
  int countt = 1;
  for (int i = 1; i <= n; i++) {
    while (countt <= k && a[countt].s <= i) Q.push(a[countt++]);
    if (Q.empty())
      nxt[i] = i + 1;
    else {
      node fa = Q.top();
      if (fa.t < i) {
        i--;
        Q.pop();
        continue;
      }
      nxt[i] = fa.d + 1;
      val[i] = fa.w;
    }
  }
  memset(f, 0x3f, sizeof(f));
  f[0][0] = 0;
  for (long long i = 0; i <= n; i++)
    for (long long j = 0; j <= m; j++) {
      f[i + 1][j + 1] = min(f[i + 1][j + 1], f[i][j]);
      f[nxt[i]][j] = min(f[nxt[i]][j], f[i][j] + val[i]);
    }
  long long total = 0x3f3f3f3f3f3f3fll;
  for (long long i = 0; i <= m; i++) {
    total = min(total, f[n + 1][i]);
  }
  printf("%lld\n", total);
  return 0;
}
