#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
vector<pair<int, int>> start[N], endd[N];
multiset<pair<int, int>> ms;
pair<int, int> ans[N];
long long dp[201][N];
int main() {
  cout << fixed << setprecision(12), ios::sync_with_stdio(false),
      cin.tie(nullptr), cout.tie(nullptr);
  int n, m, k, s, t, d, w;
  cin >> n >> m >> k;
  for (int i = 0; i < k; ++i) {
    cin >> s >> t >> d >> w;
    start[s].push_back({w, d});
    endd[t].push_back({w, d});
  }
  for (int i = 1; i <= n + 1; ++i) {
    for (auto it : start[i]) ms.insert(it);
    if (ms.empty())
      ans[i] = {0, i};
    else
      ans[i] = *ms.rbegin();
    for (auto it : endd[i]) ms.erase(ms.find(it));
  }
  memset(dp, 0x3f, sizeof dp);
  dp[0][1] = 0;
  long long total = 1e18;
  for (int j = 0; j <= m; ++j) {
    for (int i = 1; i <= n + 1; ++i) {
      dp[j + 1][i] = min(dp[j + 1][i], dp[j][i - 1]);
      dp[j][ans[i].second + 1] =
          min(dp[j][ans[i].second + 1], dp[j][i] + ans[i].first);
    }
    total = min(total, dp[j][n + 1]);
  }
  cout << total;
  return 0;
}
