#include <bits/stdc++.h>
const int MAXT = 100010;
const int MAXK = 210;
const int MAXN = 100010;
int T, K, N;
std::vector<int> start;
std::vector<int> end;
std::vector<int> defer;
std::vector<int64_t> coins;
int64_t dp[MAXT][MAXK];
struct Cmp {
  bool operator()(const int& a, const int& b) const {
    return coins[a] != coins[b] ? coins[a] > coins[b] : defer[a] > defer[b];
  }
};
int main(void) {
  std::cin >> T >> K >> N;
  T += 5;
  for (int i = 0; i < N; ++i) {
    int s, e, d, c;
    std::cin >> s >> e >> d >> c;
    start.push_back(s - 1);
    end.push_back(e);
    defer.push_back(d + 1);
    coins.push_back(c);
  }
  std::vector<std::pair<int, std::pair<int, bool>>> events;
  for (int i = 0; i < N; ++i) {
    events.push_back(std::make_pair(start[i], std::make_pair(i, false)));
    events.push_back(std::make_pair(end[i], std::make_pair(i, true)));
  }
  std::sort(events.begin(), events.end());
  std::multiset<int, Cmp> open;
  for (int i = 0; i <= K; ++i) {
    dp[T][i] = 0;
  }
  int event_idx = events.size() - 1;
  for (int i = T - 1; i >= 0; --i) {
    while (event_idx >= 0 && events[event_idx].first == i) {
      if (events[event_idx].second.second) {
        open.insert(events[event_idx].second.first);
      } else {
        open.erase(open.find(events[event_idx].second.first));
      }
      event_idx -= 1;
    }
    for (int k = 0; k <= K; ++k) {
      dp[i][k] = open.size()
                     ? coins[*open.begin()] + dp[defer[*open.begin()]][k]
                     : dp[i + 1][k];
      if (k) {
        dp[i][k] = std::min(dp[i][k], dp[i + 1][k - 1]);
      }
    }
  }
  std::cout << dp[0][K] << std::endl;
  return 0;
}
