#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
struct node {
  long long s, t, d, w, id;
  bool operator<(const node &a) const {
    if (w != a.w) return w < a.w;
    return d < a.d;
  }
} Q[100005];
long long cmp(node a, node b) { return a.s < b.s; }
priority_queue<node> q;
long long n, m, k, f[100005][205], pos[100005], now;
signed main() {
  n = read();
  m = read();
  k = read();
  now = 1;
  for (long long i = 1; i <= k; i++)
    Q[i].s = read(), Q[i].t = read(), Q[i].d = read(), Q[i].w = read();
  sort(Q + 1, Q + 1 + k, cmp);
  for (long long i = 1; i <= n; i++) {
    while (now <= k && Q[now].s <= i)
      q.push((node){Q[now].s, Q[now].t, Q[now].d, Q[now].w, now}), now++;
    while (q.size() && q.top().t < i) q.pop();
    if (q.size()) pos[i] = q.top().id;
  }
  memset(f, 127 / 3, sizeof(f));
  f[1][0] = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j <= m; j++) {
      f[i + 1][j + 1] = min(f[i][j], f[i + 1][j + 1]);
      if (pos[i])
        f[Q[pos[i]].d + 1][j] =
            min(f[Q[pos[i]].d + 1][j], f[i][j] + Q[pos[i]].w);
      else
        f[i + 1][j] = min(f[i + 1][j], f[i][j]);
    }
  }
  long long ans = 1e18;
  for (long long i = 0; i <= m; i++) ans = min(ans, f[n + 1][i]);
  printf("%lld\n", ans);
  return 0;
}
