#include <bits/stdc++.h>
using namespace std;
template <typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
template <typename T>
inline T mod(T n, T mod) {
  T res = n % mod;
  if (res < 0) res += mod;
  return res;
}
const int N = 1e5 + 5;
int n, m, k;
long long dp[N][205];
priority_queue<pair<long long, pair<int, int>>> pq;
int best[N];
struct cara {
  long long coins;
  int ini, fim, d;
};
bool cmp(cara a, cara b) { return a.fim > b.fim; }
cara v[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++) {
    cin >> v[i].ini >> v[i].fim >> v[i].d >> v[i].coins;
  }
  sort(v, v + k, cmp);
  int ptr = 0;
  for (int i = n; i >= 1; i--) {
    while (!pq.empty() and v[pq.top().second.second].ini > i) pq.pop();
    while (ptr < k and v[ptr].fim >= i) {
      pq.push({v[ptr].coins, {v[ptr].d, ptr}});
      ptr++;
    }
    if (!pq.empty())
      best[i] = pq.top().second.second;
    else
      best[i] = -1;
  }
  for (int i = n; i >= 1; i--) {
    for (int j = 0; j <= m; j++) {
      if (best[i] == -1)
        dp[i][j] = dp[i + 1][j];
      else {
        dp[i][j] = dp[v[best[i]].d + 1][j] + v[best[i]].coins;
        if (j) dp[i][j] = min(dp[i][j], dp[i + 1][j - 1]);
      }
    }
  }
  cout << dp[1][m] << endl;
  return 0;
}
