#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int s[N], t[N], d[N], w[N];
using pii = pair<int, int>;
using piii = pair<pii, int>;
pii a[N], b[N];
set<piii, greater<piii> > st;
using ll = long long;
ll dp[N][205];
int co[N];
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; ++i) {
    scanf("%d%d%d%d", &s[i], &t[i], &d[i], &w[i]);
    a[i] = {s[i], i};
    b[i] = {t[i], i};
  }
  sort(a + 1, a + 1 + k);
  sort(b + 1, b + 1 + k);
  int p = 1, q = 1;
  for (int i = 1; i <= n; ++i) {
    while (p <= k && a[p].first <= i) {
      int t = a[p].second;
      st.insert({{w[t], d[t]}, t});
      p++;
    }
    if (st.empty())
      co[i] = -1;
    else
      co[i] = (*st.begin()).second;
    while (q <= k && b[q].first <= i) {
      int t = b[q].second;
      st.erase({{w[t], d[t]}, t});
      q++;
    }
  }
  for (int i = n; i >= 1; --i) {
    if (co[i] == -1) {
      for (int j = 0; j <= m; ++j) dp[i][j] = dp[i + 1][j];
      continue;
    }
    dp[i][0] = dp[d[co[i]] + 1][0] + w[co[i]];
    for (int j = 1; j <= m; ++j)
      dp[i][j] = min(dp[i + 1][j - 1], dp[d[co[i]] + 1][j] + w[co[i]]);
  }
  ll ans = dp[1][0];
  for (int j = 1; j <= m; ++j) ans = min(dp[1][j], ans);
  printf("%lld\n", ans);
  return 0;
}
