#include <bits/stdc++.h>
using namespace std;
int N, M, K;
struct node {
  int ti = -1;
  long long v = -1;
  friend bool operator<(node a, node b) {
    if (a.v != b.v) return a.v < b.v;
    return a.ti < b.ti;
  }
};
node bin[100005];
struct ee {
  node v, laz;
  int l, r;
} e[100005 * 4];
node chk(node a, node b) { return a < b ? b : a; }
void update(int x) { e[x].v = chk(e[(x << 1)].v, e[(x << 1) + 1].v); }
void push(int x) {
  if (e[x].laz.ti != -1) {
    e[(x << 1)].v = chk(e[x].laz, e[(x << 1)].v);
    e[(x << 1) + 1].v = chk(e[x].laz, e[(x << 1) + 1].v);
    e[(x << 1)].laz = chk(e[x].laz, e[(x << 1)].laz);
    e[(x << 1) + 1].laz = chk(e[x].laz, e[(x << 1) + 1].laz);
  }
}
void build(int l, int r, int x) {
  if (l > r) return;
  e[x].l = l, e[x].r = r;
  if (l == r) return;
  int mid = (e[x].l + e[x].r) >> 1;
  build(l, mid, (x << 1));
  build(mid + 1, r, (x << 1) + 1);
}
void add(int l, int r, int x, node v) {
  if (e[x].l >= l && e[x].r <= r) {
    e[x].v = chk(v, e[x].v);
    e[x].laz = chk(e[x].laz, v);
    return;
  }
  int mid = (e[x].l + e[x].r) >> 1;
  push(x);
  if (l <= mid) add(l, r, (x << 1), v);
  if (r > mid) add(l, r, (x << 1) + 1, v);
  update(x);
}
node query(int p, int x) {
  if (e[x].l == e[x].r) return e[x].v;
  int mid = (e[x].l + e[x].r) >> 1;
  push(x);
  if (p <= mid)
    return query(p, (x << 1));
  else
    return query(p, (x << 1) + 1);
  update(x);
}
long long dp[100005][203];
int main() {
  cin >> N >> M >> K;
  build(1, N, 1);
  for (int i = 1; i <= K; i++) {
    int f, t, vv;
    long long w;
    cin >> f >> t >> vv >> w;
    node sub;
    sub.ti = vv, sub.v = w;
    add(f, t, 1, sub);
  }
  for (int i = 1; i <= N; i++) bin[i] = query(i, 1);
  memset(dp, 127, sizeof(dp));
  dp[1][0] = 0;
  for (int i = 1; i <= N; i++)
    for (int j = 0; j <= M; j++) {
      if (dp[i][j] >= 1000000000000000) continue;
      if (bin[i].ti == -1) {
        dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);
      } else {
        if (j < 200) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]);
        dp[bin[i].ti + 1][j] = min(dp[bin[i].ti + 1][j], dp[i][j] + bin[i].v);
      }
    }
  long long mint = 1000000000000000;
  for (int i = 0; i <= M; i++) mint = min(dp[N + 1][i], mint);
  cout << mint << endl;
  return 0;
}
