#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, M = 205;
long long n, m, k, dp[N][M], x, y, z, h, out = 1e18;
priority_queue<pair<long long, pair<long long, pair<int, int> > > > pq;
pair<long long, long long> tree[N << 2], lazy[N << 2];
void propagate(int s, int e, int idx) {
  if (lazy[idx].first) {
    tree[idx] = max(tree[idx], lazy[idx]);
    if (s != e) lazy[idx << 1] = lazy[idx << 1 | 1] = lazy[idx];
    lazy[idx] = {0, 0};
  }
}
void udt(int l, int r, long long w, long long d, int s = 1, int e = n,
         int idx = 1) {
  if (r < s || l > e) return;
  propagate(s, e, idx);
  if (l <= s && r >= e) {
    pair<long long, long long> to = {w, d};
    tree[idx] = max(tree[idx], to);
    if (s != e) lazy[idx << 1] = lazy[idx << 1 | 1] = tree[idx];
    return;
  }
  int mid = (s + e) >> 1;
  udt(l, r, w, d, s, mid, idx << 1);
  udt(l, r, w, d, mid + 1, e, idx << 1 | 1);
  tree[idx] = max(tree[idx << 1], tree[idx << 1 | 1]);
}
pair<long long, long long> qry(int p, int s = 1, int e = n, int idx = 1) {
  propagate(s, e, idx);
  if (s == e) return tree[idx];
  pair<long long, long long> re;
  int mid = (s + e) >> 1;
  if (p <= mid)
    re = qry(p, s, mid, idx << 1);
  else
    re = qry(p, mid + 1, e, idx << 1 | 1);
  return re;
}
int main() {
  ios::sync_with_stdio(0), cout.tie(0), cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++) {
    cin >> x >> y >> z >> h;
    pq.push({-h, {-z, {x, y}}});
  }
  while (!pq.empty()) {
    udt(pq.top().second.second.first, pq.top().second.second.second,
        -pq.top().first, -pq.top().second.first);
    pq.pop();
  }
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) dp[i][j] = 1e18;
  dp[n + 1][0] = 0;
  for (int i = n; i >= 1; i--) {
    pair<long long, long long> re = qry(i);
    for (int j = 0; j <= m; j++) {
      if (j) {
        dp[i][j] = min(
            dp[i][j], dp[max((long long)(i + 1), re.second + 1)][j] + re.first);
        dp[i][j] = min(dp[i][j], dp[i + 1][j - 1]);
      } else
        dp[i][j] = min(dp[i][j],
                       dp[max((long long)i + 1, re.second + 1)][j] + re.first);
    }
  }
  for (int i = 0; i <= m; i++) out = min(out, dp[1][i]);
  cout << out;
  return 0;
}
