#include <bits/stdc++.h>
using namespace std;
multiset<pair<long long, long long> > s;
vector<vector<pair<long long, long long> > > st, en;
vector<pair<long long, long long> > gud;
long long n, m, k;
long long dp[100009][210];
long long f(long long pos, long long baki) {
  if (pos > n) return 0;
  long long &res = dp[pos][baki];
  if (res != -1) return dp[pos][baki];
  long long nxt = gud[pos].second;
  if (nxt == 0) nxt = pos;
  res = gud[pos].first + f(nxt + 1, baki);
  if (baki > 0) res = min(res, f(pos + 1, baki - 1));
  return res;
}
int main() {
  cin >> n >> m >> k;
  gud.assign(n + 4, pair<long long, long long>(0, 0));
  st.assign(n + 4, vector<pair<long long, long long> >());
  en.assign(n + 4, vector<pair<long long, long long> >());
  memset(dp, -1, sizeof dp);
  for (long long i = 0; i < k; i++) {
    long long si, ti, di, wi;
    cin >> si >> ti >> di >> wi;
    st[si].push_back(pair<long long, long long>(wi, di));
    en[ti].push_back(pair<long long, long long>(wi, di));
  }
  for (long long i = 1; i <= n; i++) {
    for (auto pr : st[i]) s.insert(pr);
    if (s.size() > 0) gud[i] = *(s.rbegin());
    for (auto pr : en[i]) s.erase(s.find(pr));
  }
  cout << f(1, m);
  return 0;
}
