#include <bits/stdc++.h>
using namespace std;
struct Envelope {
  int s, t, d, w;
};
const int NMAX = 100010, MMAX = 210, KMAX = 100010;
const long long LLINF = 0x7fffffffffffffffLL;
int n, m, k;
Envelope red[KMAX];
vector<int> v[NMAX];
int red_t[NMAX];
long long f[NMAX][MMAX];
bool cmp(int a, int b) {
  if (red[a].w != red[b].w) return red[a].w > red[b].w;
  if (red[a].d != red[b].d) return red[a].d > red[b].d;
  return a < b;
}
set<int, decltype(cmp) *> s(cmp);
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d%d%d%d", &red[i].s, &red[i].t, &red[i].d, &red[i].w);
    v[red[i].s].push_back(i);
    v[red[i].t + 1].push_back(-i);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < v[i].size(); j++) {
      if (v[i][j] < 0) {
        s.erase(-v[i][j]);
      } else {
        s.insert(v[i][j]);
      }
    }
    auto iter = s.begin();
    red_t[i] = -1;
    if (iter != s.end()) red_t[i] = *iter;
  }
  for (int i = 1; i <= n + 1; i++)
    for (int j = 0; j <= m; j++) f[i][j] = LLINF;
  f[1][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (f[i][j] == LLINF) continue;
      int cur = red_t[i];
      long long &trans1 = f[red[cur].d + 1][j];
      long long &trans2 = f[i + 1][j + 1];
      long long &trans3 = f[i + 1][j];
      if (cur == -1) {
        trans3 = min(trans3, f[i][j]);
        continue;
      }
      trans1 = min(trans1, f[i][j] + red[cur].w);
      if (j != m) trans2 = min(trans2, f[i][j]);
    }
  }
  long long ans = LLINF;
  for (int i = 0; i <= m; i++) ans = min(ans, f[n + 1][i]);
  cout << ans << endl;
  return 0;
}
