#include <bits/stdc++.h>
using namespace std;
const int SI = 1e5 + 100;
struct node {
  int d, w, id;
  bool operator<(const node& A) const {
    if (w != A.w) return w < A.w;
    return d < A.d;
  }
};
priority_queue<node> q;
int ad[SI];
node old[SI];
vector<int> L[SI], R[SI];
int n, m, k;
bool in[SI];
long long dp[100005][205];
int main() {
  scanf("%d %d %d", &n, &m, &k);
  int l, r, e, w;
  for (int i = 1; i <= k; ++i) {
    scanf("%d %d %d %d", &l, &r, &e, &w);
    r++;
    L[l].push_back(i);
    R[r].push_back(i);
    old[i].d = e;
    old[i].w = w;
    old[i].id = i;
  }
  for (int i = 1; i <= n; i++) {
    for (auto it : L[i]) {
      q.push(old[it]);
      in[it] = true;
    }
    for (auto it : R[i]) in[it] = false;
    while (q.empty() == false) {
      node temp = q.top();
      if (in[temp.id] == false)
        q.pop();
      else {
        ad[i] = temp.id;
        break;
      }
    }
  }
  node mon;
  long long res = 1e14;
  memset(dp, 0x3f, sizeof(dp));
  dp[n + 1][0] = 0;
  for (int i = n; i >= 1; i--) {
    if (ad[i] > 0)
      mon = old[ad[i]];
    else {
      mon.w = 0;
      mon.d = i;
    }
    dp[i][0] = dp[mon.d + 1][0] + mon.w;
    for (int j = 1; j <= m && j <= n - i + 1; j++)
      dp[i][j] = ((dp[i + 1][j - 1]) < (dp[mon.d + 1][j] + mon.w)
                      ? (dp[i + 1][j - 1])
                      : (dp[mon.d + 1][j] + mon.w));
  }
  for (int i = 0; i <= m; i++) res = ((res) < (dp[1][i]) ? (res) : (dp[1][i]));
  printf("%I64d", res);
  return 0;
}
