#include <bits/stdc++.h>
using namespace std;
struct Event {
  int d, w, t;
  bool operator<(const Event &e) const {
    return w > e.w || (w == e.w && d > e.d);
  }
};
vector<Event> e[100010];
Event a[100010];
map<Event, int> cur;
int n, m, k;
long long f[2][100010], ans = 0x3f3f3f3f3f3f3f3fLL;
void insert(Event x) {
  if (cur.count(x)) {
    cur[x]++;
  } else {
    cur[x] = 1;
  }
}
void erase(Event x) {
  cur[x]--;
  if (cur[x] == 0) {
    cur.erase(x);
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    int s, t, d, w;
    scanf("%d%d%d%d", &s, &t, &d, &w);
    e[s].push_back((Event){d, w, 1});
    e[t + 1].push_back((Event){d, w, -1});
  }
  for (int i = 1; i <= n; i++) {
    for (auto p : e[i]) {
      if (p.t == 1) {
        insert(p);
      } else {
        erase(p);
      }
    }
    if (cur.size()) {
      a[i] = (*cur.begin()).first;
    } else {
      a[i] = (Event){i, 0, 0};
    }
  }
  memset(f, 0x3f, sizeof(f));
  f[0][1] = 0;
  for (int j = 0; j <= m; j++) {
    memset(f[(j ^ 1) & 1], 0x3f, sizeof(f[(j ^ 1) & 1]));
    for (int i = 1; i <= n; i++) {
      f[(j ^ 1) & 1][i + 1] = min(f[(j ^ 1) & 1][i + 1], f[j & 1][i]);
      f[j & 1][a[i].d + 1] = min(f[j & 1][a[i].d + 1], f[j & 1][i] + a[i].w);
    }
    ans = min(ans, f[j & 1][n + 1]);
  }
  printf("%lld\n", ans);
  return 0;
}
