#include <bits/stdc++.h>
using namespace std;
int n, m, k;
struct Eve {
  int w, d;
  bool end;
  bool operator<(const Eve &op) const {
    return w > op.w || (w == op.w && d > op.d);
  }
} Time[100005];
vector<Eve> T[100005];
long long poi[2][100005], ans = 0x3f3f3f3f3f3f3f3fUL;
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++) {
    int s, t, d, w;
    scanf("%d%d%d%d", &s, &t, &d, &w);
    T[s].push_back((Eve){w, d, 0});
    T[t + 1].push_back((Eve){w, d, 1});
  }
  multiset<Eve> s;
  for (int i = 1; i <= n; i++) {
    for (auto j : T[i])
      if (j.end)
        s.erase(s.find(j));
      else
        s.insert(j);
    if (s.size())
      Time[i] = *s.begin();
    else
      Time[i] = (Eve){0, i, 0};
  }
  memset(poi, 0x3f, sizeof(poi));
  poi[1][1] = 0;
  for (int i = 0; i <= m; i++) {
    int cn = i & 1;
    memset(poi[cn], 0x3f, sizeof(poi[cn]));
    for (int j = 1; j <= n; j++) {
      poi[cn][j + 1] = min(poi[cn][j + 1], poi[!cn][j]);
      poi[!cn][Time[j].d + 1] =
          min(poi[!cn][Time[j].d + 1], poi[!cn][j] + Time[j].w);
    }
    ans = min(ans, poi[!cn][n + 1]);
  }
  printf("%lld", ans);
  return 0;
}
