#include <bits/stdc++.h>
using namespace std;
long long dp[100005][205];
int n, m, k, b[100005], e[100005], to[100005], pr[100005];
vector<int> fin[100005], st[100005];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  int m;
  int f;
  cin >> n >> m >> f;
  for (int i = 0; i < f; i++) {
    cin >> b[i] >> e[i] >> to[i] >> pr[i];
    st[b[i]].push_back(i);
    fin[e[i] + 1].push_back(i);
  }
  fill(dp[0], dp[100004] + 205, 1e18);
  multiset<pair<int, int> > sret;
  dp[1][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (auto it : st[i]) sret.insert({pr[it], to[it]});
    for (auto it : fin[i]) sret.erase(sret.find({pr[it], to[it]}));
    pair<int, int> my = {0, i};
    if (!sret.empty()) my = *sret.rbegin();
    int pric = my.first;
    int eda = my.second;
    for (int j = 0; j <= m; j++) {
      dp[eda + 1][j] = min(dp[eda + 1][j], dp[i][j] + pric);
      dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]);
    }
  }
  long long ans = dp[n + 1][0];
  for (int i = 0; i <= m; i++) {
    ans = min(ans, dp[n + 1][i]);
  }
  cout << ans;
  cin >> ans;
}
