#include <bits/stdc++.h>
using namespace std;
int n, m, k, x, y, z, l, r, sz;
long long dp[111111][222], ans;
pair<int, int> tree[444444], cur;
void update(int beg, int en, int l, int r, int node, pair<int, int> add) {
  if (l > en || r < beg) return;
  if (l >= beg && r <= en) {
    tree[node] = max(tree[node], add);
    return;
  }
  int mid = (l + r) >> 1;
  update(beg, en, l, mid, node << 1, add);
  update(beg, en, mid + 1, r, (node << 1) | 1, add);
}
pair<int, int> query(int x) {
  pair<int, int> res = make_pair(0, 0);
  int pos = sz - 1 + x;
  while (pos >= 1) {
    res = max(res, tree[pos]);
    pos >>= 1;
  }
  return res;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  sz = 1;
  while (sz < n) sz *= 2;
  for (int i = 1; i <= k; i++) {
    scanf("%d%d%d%d", &l, &r, &x, &y);
    update(l, r, 1, sz, 1, make_pair(y, x));
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) dp[i][j] = 1e18;
  }
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= m; j++) {
      if (dp[i][j] > 1e17) continue;
      dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]);
      cur = query(i + 1);
      if (!cur.second)
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      else
        dp[cur.second][j] =
            min(dp[cur.second][j], dp[i][j] + (long long)cur.first);
    }
  }
  ans = 1e18;
  for (int i = 0; i <= m; i++) {
    ans = min(ans, dp[n][i]);
  }
  printf("%lld\n", ans);
  return 0;
}
