#include <bits/stdc++.h>
long long memo[100005][205];
std::pair<long long, int> pre[100005];
int n;
struct q4 {
  int s, t, d, pin;
  long long w;
  bool operator<(const q4& wx) const {
    return ((w > wx.w) || ((w == wx.w) && (d > wx.d)));
  }
};
std::vector<q4> Q[100005];
std::multiset<q4> X;
long long BALLIA(int z, int m) {
  if (m < 0)
    return 100000000000000001;
  else if (z > n)
    return 0;
  if (memo[z][m] != -1) return memo[z][m];
  long long ans = 100000000000000001;
  if (pre[z] != std::make_pair(0LL, 0))
    ans = std::min(pre[z].first + BALLIA(pre[z].second + 1, m),
                   BALLIA(z + 1, m - 1));
  else
    ans = BALLIA(z + 1, m);
  memo[z][m] = ans;
  return ans;
}
int main(void) {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(NULL);
  memset(memo, -1, sizeof(memo));
  int m, k;
  std::cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) pre[i] = std::make_pair(0LL, 0);
  for (int i = 1; i <= k; i++) {
    int s, t, d;
    long long w;
    std::cin >> s >> t >> d >> w;
    Q[s].push_back({s, t, d, 1, w});
    Q[t + 1].push_back({s, t, d, -1, w});
  }
  for (int i = 1; i <= n; i++) {
    for (auto u : Q[i]) {
      if (u.pin == 1)
        X.insert(u);
      else
        X.erase(X.find({u.s, u.t, u.d, 1, u.w}));
    }
    if (!X.empty())
      pre[i] = std::make_pair((*X.begin()).w, (*X.begin()).d);
    else
      pre[i] = std::make_pair(0LL, 0);
  }
  long long ans = BALLIA(1, m);
  std::cout << ans << "\n";
  return 0;
}
