#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> best[100001];
long long dp[100005][205];
int n;
long long fun(long long ind, long long m) {
  if (ind > n) {
    return 0;
  }
  if (dp[ind][m] != -1) {
    return dp[ind][m];
  }
  if (best[ind].first == -1) {
    return fun(ind + 1, m);
  }
  long long ans = 0;
  if (m == 0) {
    ans = best[ind].first + fun(best[ind].second + 1, m);
  } else {
    ans = min(best[ind].first + fun(best[ind].second + 1, m),
              fun(ind + 1, m - 1));
  }
  dp[ind][m] = ans;
  return ans;
}
int main() {
  memset(dp, -1, sizeof(dp));
  int m, k;
  cin >> n >> m >> k;
  vector<pair<long long, long long> > tmp[n + 2];
  for (int i = 0; i < k; i++) {
    long long s, t, d, w;
    cin >> s >> t >> d >> w;
    tmp[s].push_back({w, d});
    tmp[t + 1].push_back({-w, d});
  }
  multiset<pair<long long, long long> > track;
  for (int i = 1; i <= n; i++) {
    for (auto j : tmp[i]) {
      if (j.first > 0) {
        track.insert(j);
      } else {
        track.erase(track.find({-j.first, j.second}));
      }
    }
    if (track.size() == 0) {
      best[i] = {-1, -1};
      continue;
    }
    auto t = *track.rbegin();
    best[i] = t;
  }
  long long ans = fun(1, m);
  cout << ans << '\n';
}
