#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool upmax(T &x, T y) {
  return x < y ? (x = y, 1) : 0;
}
template <typename T>
inline bool upmin(T &x, T y) {
  return x > y ? (x = y, 1) : 0;
}
namespace MATH_CAL {
const int mod = 1e9 + 7;
inline int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
inline int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
inline int mul(int a, int b) { return (long long)a * b % mod; }
inline void Add(int &a, int b) { (a += b) >= mod ? a -= mod : 0; }
inline void Sub(int &a, int b) { (a -= b) < 0 ? a += mod : 0; }
inline int qpow(int x, int n) {
  int r = 1;
  for (; n; n /= 2, x = mul(x, x))
    if (n & 1) r = mul(r, x);
  return r;
}
inline int mod_inv(int x) { return qpow(x, mod - 2); }
}  // namespace MATH_CAL
const int MAX_N = 1e5 + 10;
const int MAX_M = 205;
const int inf = 1ll << 60;
struct info {
  int l, r, d, v;
  inline bool operator<(const info &b) const {
    return v > b.v or (v == b.v and d > b.d);
  }
} e[MAX_N];
long long f[MAX_N][MAX_M];
int vis[MAX_N], nxt[MAX_N], gain[MAX_N];
int fa[MAX_N];
inline int Find(int x) { return fa[x] == x ? x : fa[x] = Find(fa[x]); }
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = (0), _ = (k); i < _; ++i) {
    int l, r, d, v;
    scanf("%d%d%d%d", &l, &r, &d, &v);
    e[i] = {l, r, d, v};
  }
  sort(e, e + k);
  for (int i = 1; i <= n + 1; ++i) fa[i] = i;
  for (int i = 0; i < k; ++i) {
    int p = Find(e[i].l);
    while (p <= e[i].r) {
      vis[p] = 1;
      nxt[p] = e[i].d + 1;
      gain[p] = e[i].v;
      fa[p] = p + 1;
      p = Find(p);
    }
  }
  for (int i = (0), _ = (m + 1); i < _; ++i) f[n + 1][i] = 0;
  for (int i = (n + 1) - 1, _ = (1); i >= _; --i) {
    for (int j = (0), _ = (m + 1); j < _; ++j) {
      f[i][j] = vis[i] ? f[nxt[i]][j] + gain[i] : f[i + 1][j];
      if (j > 0) {
        f[i][j] = min(f[i][j], f[i + 1][j - 1]);
      }
    }
  }
  long long ans = f[1][m];
  printf("%lld\n", ans);
  return 0;
}
