#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 10;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
struct lenka {
  long long s, t, d, w;
  bool operator<(const lenka& q) const {
    if (q.w != w) return q.w > w;
    return q.d > d;
  }
} A[MAX];
int cmp(const lenka& p, const lenka& q) { return p.s < q.s; }
void Min(long long& x, long long y) {
  if (y == -1) return;
  x = (x == -1 ? y : min(x, y));
}
long long d[MAX][201];
priority_queue<lenka> p;
int main() {
  int N, M, K;
  cin >> N >> M >> K;
  for (int i = 1; i <= K; i++)
    scanf("%lld%lld%lld%lld", &A[i].s, &A[i].t, &A[i].d, &A[i].w);
  sort(A + 1, A + K + 1, cmp);
  memset(d, -1, sizeof d);
  d[1][0] = 0;
  int now = 1;
  for (int i = 1; i <= N; i++) {
    while (now <= K && A[now].s <= i) p.push(A[now]), now++;
    while (!p.empty() && p.top().t < i) p.pop();
    if (p.empty()) {
      for (int j = 0; j <= M; j++) Min(d[i + 1][j], d[i][j]);
      continue;
    }
    lenka Q = p.top();
    for (int j = 0; j <= M; j++) {
      if (d[i][j] == -1) continue;
      Min(d[min(N + 1ll, Q.d + 1)][j], d[i][j] + Q.w);
      if (j < M) Min(d[min(N + 1, i + 1)][j + 1], d[i][j]);
    }
  }
  printf("%lld\n", max(0ll, *min_element(d[N + 1], d[N + 1] + M + 1)));
  return 0;
}
