#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 10;
const long long inf = (long long)2e16;
vector<int> start[N], fin[N];
int opt[N], w[N], d[N], n, k, m;
long long dp[N][205];
long long F(int pos, int dis) {
  if (dis > m) return inf;
  if (pos > n) return 0LL;
  long long &ret = dp[pos][dis];
  if (ret != -1LL) return ret;
  ret = F(pos + 1, dis + 1);
  if (opt[pos] > 0)
    ret = min(ret, F(d[opt[pos]] + 1, dis) + w[opt[pos]]);
  else
    ret = min(ret, F(pos + 1, dis));
  return ret;
}
int main() {
  memset(dp, -1, sizeof(dp));
  memset(opt, 0, sizeof(opt));
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    int a, b;
    scanf("%d %d %d %d", &a, &b, &d[i], &w[i]);
    start[a].push_back(i);
    fin[b].push_back(i);
  }
  set<pair<pair<int, int>, int> > s;
  for (int i = 1; i <= n; i++) {
    for (int indx : start[i]) {
      s.insert({{w[indx], d[indx]}, indx});
    }
    if (!s.empty()) {
      opt[i] = (*s.rbegin()).second;
    }
    for (int indx : fin[i]) {
      s.erase({{w[indx], d[indx]}, indx});
    }
  }
  printf("%lld\n", F(1, 0));
  return 0;
}
