#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
long long dp[maxn][210];
struct sa {
  int l, r, d, w;
  bool operator<(sa a) const {
    if (w == a.w) {
      return d < a.d;
    }
    return w < a.w;
  }
} seg[maxn];
priority_queue<sa> q;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  memset(dp, 0x3f, sizeof(dp));
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < k; ++i) {
    cin >> seg[i].l >> seg[i].r >> seg[i].d >> seg[i].w;
  }
  sort(seg, seg + k, [&](sa a, sa b) { return a.l < b.l; });
  dp[1][0] = 0;
  int ind = 0;
  for (int i = 1; i <= n; ++i) {
    while (ind < k) {
      if (seg[ind].l > i) {
        break;
      } else if (seg[ind].r < i) {
        ind++;
      } else {
        q.push(seg[ind]);
        ++ind;
      }
    }
    sa tmp;
    bool is = 0;
    while (!q.empty()) {
      tmp = q.top();
      if (tmp.r < i) {
        q.pop();
      } else {
        is = 1;
        break;
      }
    }
    for (int j = 0; j <= m; ++j) {
      if (is) {
        dp[tmp.d + 1][j] = min(dp[tmp.d + 1][j], dp[i][j] + tmp.w);
      } else {
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      }
      dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]);
    }
  }
  cout << *min_element(dp[n + 1], dp[n + 1] + m + 1) << endl;
  return 0;
}
