#include <bits/stdc++.h>
using namespace std;
struct node {
  int st, ed, d, val;
  friend bool operator<(node a, node b) {
    if (a.val == b.val) return a.d < b.d;
    return a.val < b.val;
  }
} ee[100005];
bool cmp(node a, node b) { return a.st < b.st; }
long long dp[100005][205];
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++)
    scanf("%d%d%d%d", &ee[i].st, &ee[i].ed, &ee[i].d, &ee[i].val);
  sort(ee + 1, ee + k + 1, cmp);
  for (int i = 0; i < 100005; i++)
    for (int j = 0; j < 205; j++) dp[i][j] = 1e18;
  dp[ee[1].st][0] = 0;
  int pos = 1;
  priority_queue<node> que;
  for (int i = ee[1].st; i <= n; i++) {
    while (pos <= k && ee[pos].st == i) que.push(ee[pos]), pos++;
    while (que.size() && que.top().ed < i) que.pop();
    if (que.size() == 0) {
      for (int j = 0; j <= m; j++) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
    } else {
      node x = que.top();
      for (int j = 0; j <= m; j++) {
        dp[x.d + 1][j] = min(dp[x.d + 1][j], dp[i][j] + x.val);
        dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]);
      }
    }
  }
  long long mins = 1e18;
  for (int i = 0; i <= m; i++) mins = min(mins, dp[n + 1][i]);
  printf("%lld\n", mins);
  return 0;
}
