#include <bits/stdc++.h>
using namespace std;
struct t_envelope {
  int i, f;
  long long int lucro;
  int dep;
  bool operator<(const t_envelope &o) const {
    if (lucro == o.lucro) return dep < o.dep;
    return lucro < o.lucro;
  }
};
struct t_envelope envelope[100100];
long long int lucro[100100];
int dep[100100];
int proximo[100100];
long long int pd[100100][220];
int n, minina, k;
bool compara(struct t_envelope a, struct t_envelope b) { return a.i < b.i; }
void preenche() {
  sort(envelope + 1, envelope + 1 + k, compara);
  int p = 1;
  priority_queue<struct t_envelope> fila;
  for (int i = 1; i <= n; i++) {
    while (envelope[p].i <= i && p <= k) {
      fila.push(envelope[p]);
      p++;
    }
    while (!fila.empty() && fila.top().f < i) fila.pop();
    if (!fila.empty()) {
      struct t_envelope ax = fila.top();
      lucro[i] = ax.lucro;
      dep[i] = ax.dep;
    } else {
      lucro[i] = 0;
    }
  }
}
long long int solve(int ind, int m) {
  if (ind >= n + 1) return 0;
  long long int atra = 9999999999999999;
  long long int n_atra = 9999999999999999;
  if (pd[ind][m] != -1) return pd[ind][m];
  if (m > 0) {
    atra = solve(ind + 1, m - 1);
  }
  if (lucro[ind] > 0)
    n_atra = solve(dep[ind] + 1, m) + lucro[ind];
  else
    n_atra = solve(ind + 1, m);
  return pd[ind][m] = min(atra, n_atra);
}
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  cin >> n >> minina >> k;
  int i = 0;
  for (i = 1; i <= k; i++) {
    cin >> envelope[i].i >> envelope[i].f >> envelope[i].dep >>
        envelope[i].lucro;
  }
  preenche();
  for (i = 1; i <= n + 1; i++) {
    for (int j = 0; j <= 205; j++) {
      pd[i][j] = -1;
    }
  }
  cout << solve(1, minina) << endl;
}
