#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 5;
vector<pair<int, long long> > in[maxn], out[maxn];
pair<int, long long> best[maxn];
long long dp[maxn][205];
multiset<pair<int, long long> > now;
long long n, m, k;
void tclear() {
  memset(dp, -1, sizeof(dp));
  for (long long i = 0; i <= n + 1; i++) in[i].clear(), out[i].clear();
}
long long dfs(long long place, long long c) {
  if (place > n) return 0;
  if (dp[place][c] >= 0) return dp[place][c];
  long long res = best[place].first + dfs(best[place].second + 1, c);
  if (c < m) res = min(res, dfs(place + 1, c + 1));
  return dp[place][c] = res;
}
int main() {
  while (cin >> n >> m >> k) {
    tclear();
    long long l, r, d, w;
    for (long long i = 0; i < k; i++) {
      cin >> l >> r >> d >> w;
      in[l].push_back(make_pair(w, d));
      out[r + 1].push_back(make_pair(w, d));
    }
    for (long long i = 1; i <= n + 1; i++) {
      for (long long j = 0; j < in[i].size(); j++) now.insert(in[i][j]);
      for (long long j = 0; j < out[i].size(); j++)
        now.erase(now.find(out[i][j]));
      if (now.size())
        best[i] = *now.rbegin();
      else
        best[i] = {(long long)0, (long long)i};
    }
    cout << dfs(1, 0) << endl;
  }
}
