#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e17;
const int len = (int)1e5 + 10;
vector<vector<pair<int, int>>> start;
vector<vector<pair<int, int>>> finish;
map<pair<int, int>, int> ev;
vector<pair<int, int>> a;
long long dp[len][210];
int n, m, k;
long long solve(int i, int j) {
  if (j > m) return INF;
  if (i > n) return 0;
  if (dp[i][j] == -1) {
    dp[i][j] = min(solve(a[i].second + 1, j) + a[i].first, solve(i + 1, j + 1));
  }
  return dp[i][j];
}
int main() {
  cin >> n >> m >> k;
  start = vector<vector<pair<int, int>>>(n + 1);
  finish = vector<vector<pair<int, int>>>(n + 1);
  for (int i = 0; i < k; i++) {
    int s, t, w, l;
    cin >> s >> t >> l >> w;
    start[s].push_back({w, l});
    finish[t].push_back({w, l});
  }
  a = vector<pair<int, int>>(n + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      dp[i][j] = -1;
    }
    for (int j = 0; j < start[i].size(); j++) {
      ev[start[i][j]]++;
    }
    if (!ev.empty()) {
      a[i] = ev.rbegin()->first;
    } else {
      a[i] = {0, i};
    }
    for (int j = 0; j < finish[i].size(); j++) {
      ev[finish[i][j]]--;
      if (ev[finish[i][j]] == 0) {
        ev.erase(finish[i][j]);
      }
    }
  }
  cout << solve(1, 0) << endl;
  return 0;
}
