#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template <typename T, typename TT>
inline ostream &operator<<(ostream &os, const pair<T, TT> &t) {
  return os << t.first << " " << t.second;
}
template <typename T>
inline ostream &operator<<(ostream &os, const vector<T> &t) {
  for (auto i : t) os << i << " ";
  return os;
}
template <typename T>
inline istream &operator>>(istream &is, vector<T> &v) {
  for (T &t : v) is >> t;
  return is;
}
template <typename T1, typename T2>
inline istream &operator>>(istream &is, pair<T1, T2> &t) {
  is >> t.first >> t.second;
  return is;
}
const long long mod = 1e9 + 7;
struct cmp {
  bool operator()(const vector<long long> &a,
                  const vector<long long> &b) const {
    if (a[3] == b[3]) return a[2] > b[2];
    return a[3] > b[3];
  }
};
void solve() {
  long long n, m, k;
  cin >> n >> m >> k;
  vector<pair<long long, long long> > best(n + 1, {-1, -1});
  vector<vector<long long> > e(k, vector<long long>(4));
  cin >> e;
  sort(e.begin(), e.end());
  multiset<vector<long long>, cmp> s;
  long long j = 0;
  for (int i = 1; i <= n; i++) {
    while (!s.empty() and (*s.begin())[1] < i) s.erase(s.begin());
    while (j < k and e[j][0] <= i) s.insert(e[j++]);
    if (s.empty()) continue;
    auto &tp = *s.begin();
    best[i] = {tp[2], tp[3]};
  }
  vector<vector<long long> > dp(n + 1, vector<long long>(m + 1));
  for (long long i = n; i; i--) {
    for (long long j = 0; j <= m; j++) {
      if (best[i].first != -1)
        dp[i][j] = (best[i].first + 1 <= n ? dp[best[i].first + 1][j] : 0) +
                   best[i].second;
      else
        dp[i][j] = (i + 1 <= n ? dp[i + 1][j] : 0);
      if (j > 0) dp[i][j] = min(dp[i][j], (i + 1 <= n ? dp[i + 1][j - 1] : 0));
    }
  }
  long long ans = 1e18;
  for (int i = 0; i <= m; i++) ans = min(ans, dp[1][i]);
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ;
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
