#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int maxn = 1e5 + 10;
const int maxm = 200 + 10;
int n, m, k;
struct Even {
  int d, w, t;
  bool operator<(const Even& rhs) const {
    return w > rhs.w || (w == rhs.w && d > rhs.d);
  }
} even[maxn];
vector<Even> st[maxn], en[maxn];
long long f[maxn][maxm];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    int s, t, d, w;
    scanf("%d%d%d%d", &s, &t, &d, &w);
    st[s].push_back((Even){d, w, 1});
    en[t + 1].push_back((Even){d, w, -1});
  }
  multiset<Even> S;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < st[i].size(); j++) S.insert(st[i][j]);
    for (int j = 0; j < en[i].size(); j++) {
      multiset<Even>::iterator it = S.find(en[i][j]);
      if (it != S.end()) S.erase(it);
    }
    if (S.empty()) {
      even[i] = (Even){0, 0, 0};
    } else {
      even[i] = *S.begin();
    }
  }
  for (int i = 1; i <= n + 1; i++) {
    for (int j = 0; j <= m; j++) {
      f[i][j] = INF;
    }
  }
  f[1][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (f[i][j] >= INF) continue;
      if (even[i].w == 0) {
        f[i + 1][j] = min(f[i + 1][j], f[i][j]);
      } else {
        f[even[i].d + 1][j] = min(f[even[i].d + 1][j], f[i][j] + even[i].w);
        if (j != m) f[i + 1][j + 1] = min(f[i + 1][j + 1], f[i][j]);
      }
    }
  }
  long long ans = INF;
  for (int i = 0; i <= m; i++) ans = min(ans, f[n + 1][i]);
  printf("%I64d\n", ans);
  return 0;
}
