#icpc2015autumnh. [icpc2015autumn_h]Donut Decoration

[icpc2015autumn_h]Donut Decoration

MathJax.Hub.Config({ tex2jax: { inlineMath: [["","",""], ["\\(","\\)"]], processEscapes: true }}); blockquote { font-family: Menlo, Monaco, "Courier New", monospace; color: #333333; display: block; padding: 8.5px; margin: 0 0 9px; font-size: 12px; line-height: 18px; background-color: #f5f5f5; border: 1px solid #ccc; border: 1px solid rgba(0, 0, 0, 0.15); -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; white-space: pre; white-space: pre-wrap; word-break: break-all; word-wrap: break-word; }

Problem Statement

Donut maker's morning is early. Mr. D, who is also called Mr. Donuts, is an awesome donut maker. Also today, he goes to his kitchen and prepares to make donuts before sunrise.

In a twinkling, Mr. D finishes frying NN donuts with a practiced hand. But these donuts as they are must not be displayed in a showcase. Filling cream, dipping in chocolate, topping somehow cute, colorful things, etc., several decoration tasks are needed. There are KK tasks numbered 11 through KK, and each of them must be done exactly once in the order 1,2,ldots,K1, 2, \\ldots, K to finish the donuts as items on sale.

Instantly, Mr. D arranges the NN donuts in a row. He seems to intend to accomplish each decoration tasks sequentially at once. However, what in the world is he doing? Mr. D, who stayed up late at yesterday night, decorates only a part of the donuts in a consecutive interval for each task. It's clearly a mistake! Not only that, he does some tasks zero or several times, and the order of tasks is also disordered. The donuts which are not decorated by correct process cannot be provided as items on sale, so he should trash them.

Fortunately, there are data recording a sequence of tasks he did. The data contain the following information: for each task, the consecutive interval \[l, r\] of the decorated donuts and the ID xx of the task. Please write a program enumerating the number of the donuts which can be displayed in a showcase as items on sale for given recorded data.


Input

The input consists of a single test case. The test case is formatted as follows.

NN KK
TT
l_1l\_1 r_1r\_1 x_1x\_1
:
:
l_Tl\_T r_Tr\_T x_Tx\_T

The first line contains two integers NN and KK, where NN (1leqNleq200,0001 \\leq N \\leq 200{,}000) is the number of the donuts fried by Mr. D, and KK (1leqKleq200,0001 \\leq K \\leq 200{,}000) is the number of decoration tasks should be applied to the donuts. The second line contains a single integer TT (1leqTleq200,0001 \\leq T \\leq 200{,}000), which means the number of information about tasks Mr. D did. Each of next TT lines contains three integers l_il\_i, r_ir\_i, and x_ix\_i representing the ii-th task Mr. D did: the ii-th task was applied to the interval \[l\_i, r\_i\] (1leql_ileqr_ileqN1 \\leq l\_i \\leq r\_i \\leq N) of the donuts inclusive, and has ID x_ix\_i (1leqx_ileqK1 \\leq x\_i \\leq K).

Output

Output the number of the donuts that can be provided as items on sale.



Sample Input 1

3 2
3
1 2 1
2 3 2
3 3 1```

### Output for the Sample Input 1

```plain
1```

* * *

### Sample Input 2

```plain
5 3
6
2 3 1
1 3 2
4 5 1
2 4 3
3 5 2
5 5 3```

### Output for the Sample Input 2

```plain
2```

* * *

### Sample Input 3

```plain
10 1
2
2 9 1
5 7 1

Output for the Sample Input 3

5```

* * *