#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000;
struct HeapNode {
  int ind, w, d;
} heap[MAXN];
int cmp(HeapNode hn1, HeapNode hn2) {
  if (hn1.w < hn2.w || hn1.w == hn2.w && hn1.d < hn2.d) {
    return -1;
  }
  if (hn1.w > hn2.w || hn1.w == hn2.w && hn1.d > hn2.d) {
    return 1;
  }
  return 0;
}
struct node {
  int x;
  node *next;
} toadd[MAXN], todel[MAXN];
int heapSize = 0;
int indInHeap[MAXN], D[MAXN], W[MAXN];
int choice[MAXN];
long long F[MAXN + 1][210];
void addNode(node[], int, int);
void insert(int, int, int);
void remove(int);
int main() {
  int N, M, K;
  cin >> N >> M >> K;
  for (int i = 0; i < N; ++i) {
    toadd[i].next = todel[i].next = NULL;
  }
  for (int i = 0; i < K; ++i) {
    int s, t;
    cin >> s >> t >> D[i] >> W[i];
    --s;
    --t;
    --D[i];
    addNode(toadd, s, i);
    addNode(todel, t, i);
  }
  for (int t = 0; t < N; ++t) {
    for (node *p = toadd[t].next; p; p = p->next) {
      insert(p->x, W[p->x], D[p->x]);
    }
    if (heapSize > 0) {
      choice[t] = heap[0].ind;
    } else {
      choice[t] = -1;
    }
    for (node *p = todel[t].next; p; p = p->next) {
      remove(p->x);
    }
  }
  memset(F, 0, sizeof(F));
  for (int t = N - 1; t >= 0; --t) {
    for (int j = 0; j <= M; ++j) {
      if (choice[t] != -1) {
        F[t][j] = F[D[choice[t]] + 1][j] + W[choice[t]];
      } else {
        F[t][j] = F[t + 1][j];
      }
      if (j > 0) {
        F[t][j] = min(F[t][j], F[t + 1][j - 1]);
      }
    }
  }
  long long ans = F[0][M];
  for (int i = 0; i < M; ++i) {
    ans = min(ans, F[0][i]);
  }
  cout << ans << endl;
  return 0;
}
void addNode(node L[], int u, int v) {
  node *p = new node({v, L[u].next});
  L[u].next = p;
}
inline int getFather(int i) { return (i - 1) / 2; }
inline int getLeftChild(int i) { return i * 2 + 1; }
inline int getRightChild(int i) { return i * 2 + 2; }
void heapSwap(int i, int j) {
  HeapNode t = heap[i];
  heap[i] = heap[j];
  heap[j] = t;
  indInHeap[heap[i].ind] = i;
  indInHeap[heap[j].ind] = j;
}
int popup(int i) {
  for (; i != 0 && cmp(heap[i], heap[getFather(i)]) == 1; i = getFather(i)) {
    heapSwap(i, getFather(i));
  }
  return i;
}
int popdown(int i) {
  while (getLeftChild(i) < heapSize) {
    int t = getLeftChild(i);
    if (getRightChild(i) < heapSize &&
        cmp(heap[getRightChild(i)], heap[t]) == 1) {
      t = getRightChild(i);
    }
    if (cmp(heap[i], heap[t]) == -1) {
      heapSwap(i, t);
      i = t;
    } else
      break;
  }
  return i;
}
void insert(int ind, int w, int d) {
  heap[heapSize++] = HeapNode({ind, w, d});
  indInHeap[ind] = heapSize - 1;
  popup(heapSize - 1);
}
void remove(int ind) {
  int i = indInHeap[ind];
  heapSwap(i, heapSize - 1);
  --heapSize;
  popdown(popup(i));
}
