#include <bits/stdc++.h>
using namespace std;
int const N = 100000 + 10;
int const M = 200 + 10;
int const inf = 0x3f3f3f3f;
vector<pair<int, int> > S[N], T[N];
multiset<pair<int, int> > st;
int n, m, k;
long long dp[N][M];
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);
    S[s - 1].push_back(pair<int, int>(w, d));
    T[t].push_back(pair<int, int>(w, d));
  }
  memset(dp, inf, sizeof(dp));
  dp[n + 1][0] = 0;
  for (int i = n; i; i--) {
    for (int k = 0; k < T[i].size(); k++) st.insert(T[i][k]);
    for (int k = 0; k < S[i].size(); k++) st.erase(st.find(S[i][k]));
    if (st.empty())
      for (int j = 0; j <= m; j++) dp[i][j] = dp[i + 1][j];
    else {
      int w = st.rbegin()->first, d = st.rbegin()->second;
      for (int j = 0; j <= m; j++) dp[i][j] = dp[d + 1][j] + w;
      for (int j = 1; j <= m; j++) dp[i][j] = min(dp[i][j], dp[i + 1][j - 1]);
    }
  }
  printf("%lld\n", *min_element(dp[1], dp[1] + m + 1));
  return 0;
}
