#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, M = 210;
int s[N], t[N], d[N], w[N], current[N];
long long dp[M][N];
vector<pair<pair<int, int>, int> > event;
set<pair<pair<int, int>, int> > greed;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= k; i++) {
    cin >> s[i] >> t[i] >> d[i] >> w[i];
    event.push_back({{s[i], 0}, i});
    event.push_back({{t[i], 1}, i});
  }
  sort(event.begin(), event.end());
  int c = 0;
  for (int i = 1; i <= n; i++) {
    while (c < (int)event.size() && event[c].first.first == i &&
           event[c].first.second == 0) {
      greed.insert({{w[event[c].second], d[event[c].second]}, event[c].second});
      c++;
    }
    if ((int)greed.size()) current[i] = greed.rbegin()->second;
    while (c < (int)event.size() && event[c].first.first == i &&
           event[c].first.second == 1) {
      greed.erase({{w[event[c].second], d[event[c].second]}, event[c].second});
      c++;
    }
  }
  for (int i = n; i >= 0; i--) {
    for (int j = 1; j <= m; j++) {
      if (current[i]) {
        dp[j][i] =
            min(dp[j - 1][i + 1], dp[j][d[current[i]] + 1] + w[current[i]]);
      } else {
        dp[j][i] = dp[j][i + 1];
      }
    }
    if (current[i])
      dp[0][i] = dp[0][d[current[i]] + 1] + w[current[i]];
    else
      dp[0][i] = dp[0][i + 1];
  }
  cout << dp[m][0] << '\n';
  return 0;
}
