#include <bits/stdc++.h>
using namespace std;
string alpha = "abcdefghijklmnopqrstuvwxyz";
int MOD = 1000000007;
const int N = 100100;
long long fastP(long long b, long long p) {
  if (p == 0)
    return 1;
  else if (p == 1)
    return b;
  long long a = fastP(b, p / 2) % MOD;
  if (p % 2)
    return (((a * a) % MOD) * b) % MOD;
  else
    return (a * a) % MOD;
}
struct node {
  int s, t, d, w, idx;
  bool operator<(node x) const {
    if (x.w == w) return d > x.d;
    return w > x.w;
  }
};
bool cmp(node y, node x) {
  if (x.s == y.s) return y.t < x.t;
  return y.s < x.s;
}
int n, m, k, nxt[N], b[N];
long long dp[N][201];
node arr[N];
long long solve(int t, int rem) {
  if (t > n) return 0;
  long long& ret = dp[t][rem];
  if (~ret) return ret;
  if (rem)
    ret = solve(t + 1, rem - 1);
  else
    ret = 4000000000000000100;
  return ret = min(ret, solve(nxt[t], rem) + b[t]);
}
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &k);
  vector<node> vec;
  for (int i = 0; i < k; ++i) {
    int s, t, d, w, idx;
    scanf("%d", &s);
    scanf("%d", &t);
    scanf("%d", &d);
    scanf("%d", &w);
    vec.push_back({s, t, d, w, i});
    arr[i] = vec[i];
  }
  sort(vec.begin(), vec.end(), cmp);
  multiset<pair<int, int> > avail;
  multiset<node> mx;
  int j = 0;
  for (int i = 1; i <= n; ++i) {
    while (j < k && vec[j].s <= i && vec[j].t >= i)
      avail.insert({vec[j].t, vec[j].idx}), mx.insert(vec[j++]);
    while (!avail.empty() && avail.begin()->first < i)
      mx.erase(mx.lower_bound(arr[avail.begin()->second])),
          avail.erase(*avail.begin());
    if (!mx.empty())
      b[i] = mx.begin()->w, nxt[i] = mx.begin()->d + 1;
    else
      nxt[i] = i + 1;
  }
  memset(dp, -1, sizeof(dp));
  cout << solve(1, m) << endl;
  return 0;
}
