#include <bits/stdc++.h>
using namespace std;
const int mxn = 1e5 + 5;
int n, m, k, s, t, d, w;
long long dp[mxn][222];
multiset<pair<int, int> > S;
vector<pair<int, int> > ins[mxn], era[mxn];
int main() {
  cin >> n >> m >> k;
  for (; k--;)
    cin >> s >> t >> d >> w, ins[t].push_back(make_pair(-w, -d)),
        era[s].push_back(make_pair(-w, -d));
  for (int i = n; i; --i) {
    for (auto e : ins[i]) S.insert(e);
    for (int j = 0; j <= m; ++j) {
      dp[i][j] = S.empty()
                     ? dp[i + 1][j]
                     : dp[-(*S.begin()).second + 1][j] - (*S.begin()).first;
      if (j) dp[i][j] = min(dp[i][j], dp[i + 1][j - 1]);
    }
    for (auto e : era[i]) S.erase(S.lower_bound(e));
  }
  cout << dp[1][m] << endl;
}
