#include <bits/stdc++.h>
using namespace std;
inline void Boost() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
const int NMax = 1e5 + 50;
const long long int INF = 1e16;
struct Event {
  int d, w, t;
  bool operator<(const Event &e) const {
    if (w != e.w) return w > e.w;
    return d > e.d;
  }
};
vector<int> DP, jump;
map<Event, int> Map;
vector<Event> v[NMax];
int main() {
  Boost();
  int n, k, m;
  cin >> n >> m >> k;
  DP.resize(n);
  jump.resize(n);
  for (int i = 0; i < n; ++i) jump[i] = i + 1;
  for (int i = 0; i < k; ++i) {
    int s, t, d, w;
    cin >> s >> t >> d >> w;
    v[s - 1].push_back({d, w, 1});
    v[t].push_back({d, w, 0});
  }
  for (int i = 0; i < n; ++i) {
    for (auto x : v[i]) {
      if (x.t == 1) {
        if (Map.count(x)) {
          ++Map[x];
        } else {
          Map[x] = 1;
        }
      } else {
        --Map[x];
        if (Map[x] == 0) {
          Map.erase(x);
        }
      }
    }
    if (!Map.empty()) {
      DP[i] = (*Map.begin()).first.w;
      jump[i] = (*Map.begin()).first.d;
    }
  }
  vector<long long int> ans[2];
  for (auto &x : ans) x.resize(n + 1, INF);
  long long int ret = LLONG_MAX;
  ans[0][0] = 0;
  for (int i = 0, now = 0, next = 1; i <= m; ++i) {
    for (int j = 0; j < n; ++j) {
      ans[next][j + 1] = min(ans[next][j + 1], ans[now][j]);
      ans[now][jump[j]] = min(ans[now][jump[j]], ans[now][j] + DP[j]);
    }
    ret = min(ret, ans[now][n]);
    for (int j = 0; j <= n; ++j) ans[now][j] = INF;
    now = 1 - now;
    next = 1 - next;
  }
  cout << ret;
  return 0;
}
