#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, M = 205;
struct envelope {
  int second, t, d;
  long long w;
  bool operator<(const envelope e) const {
    if (e.w != w) return w > e.w;
    return d > e.d;
  }
};
int n, k, m, line[N];
long long dp[N][M];
envelope E[N];
void pre() {
  for (int i = 0; i < k; i++) {
    for (int j = E[i].second; j <= E[i].t; j++) {
      if (line[j] == -1)
        line[j] = i;
      else
        j = E[line[j]].t;
    }
  }
}
long long sol(int i, int rem) {
  if (i == n + 1) return 0;
  long long &ret = dp[i][rem];
  if (ret != -1) return ret;
  if (line[i] == -1) return ret = sol(i + 1, rem);
  ret = sol(E[line[i]].d + 1, rem) + E[line[i]].w;
  if (rem) ret = min(ret, sol(i + 1, rem - 1));
  return ret;
}
int main() {
  memset(dp, -1, sizeof dp);
  memset(line, -1, sizeof line);
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++)
    scanf("%d %d %d %I64d", &E[i].second, &E[i].t, &E[i].d, &E[i].w);
  sort(E, E + k);
  pre();
  cout << sol(0, m) << endl;
}
