#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
struct query {
  int ti, ty, id;
};
int N, s[100009], t[100009], d[100009], w[100009], nxt[100009], gt[100009];
long long D[209][100009];
long long go(int lft, int idx) {
  if (idx == N + 1) return 0;
  if (D[lft][idx] != -1) return D[lft][idx];
  return D[lft][idx] =
             min((long long)(lft > 0 ? go(lft - 1, idx + 1) : 1LL * 1e18),
                 go(lft, nxt[idx]) + gt[idx]);
}
int main() {
  int M, K;
  scanf("%d%d%d", &N, &M, &K);
  vector<query> Q;
  for (int i = 0; i < K; i++) {
    scanf("%d%d%d%d", &s[i], &t[i], &d[i], &w[i]);
    Q.push_back({s[i], +1, i});
    Q.push_back({t[i] + 1, -1, i});
  }
  sort(Q.begin(), Q.end(), [&](query X, query Y) { return X.ti < Y.ti; });
  multiset<pii> st;
  for (int i = 1, j = 0; i <= N; i++) {
    while (j < 2 * K && Q[j].ti <= i) {
      int idx = Q[j].id;
      if (Q[j].ty == +1)
        st.insert({w[idx], d[idx]});
      else
        st.erase(st.find({w[idx], d[idx]}));
      ++j;
    }
    if (st.empty())
      nxt[i] = i + 1, gt[i] = 0;
    else {
      pii mx = *(--st.end());
      nxt[i] = mx.second + 1;
      gt[i] = mx.first;
    }
  }
  memset(D, -1, sizeof(D));
  printf("%lld", go(M, 1));
  return 0;
}
