#GYM104617H. Cone Factory

Cone Factory

Description

You are the proud owner of an ice cream cone factory, where ice cream cones are produced by pouring batter into cone molds. The cone-producing process can be modeled as follows:

1. Cone molds are placed at integer points along the X-axis.

2. For each integer X-coordinate, there exists a batter dispenser located at height $\infty$.

3. The batter dispensers are activated, dispensing batter in a downward stream and filling the cone mold beneath it if there is one.

Normally, this process works quite well, and you are able to fill all your cone molds regardless of where they are placed. However, due to some events beyond expectation, your factory only has enough power to activate exactly one dispenser!

To alleviate this problem, you have acquired $m$ batter spreaders. The $i$th spreader exists as a horizontal line segment [$l_i$, $r_i$] at height $h_i$. Whenever a stream of batter hits anywhere on the spreader, it will evenly distribute the flow to cover the entire length of the spreader.

Despite the setbacks you've encountered, you would still like to fill as many cone molds as you can. Given the locations of your cone molds and batter spreaders, what is the maximum number of molds you can fill by activating exactly one batter dispenser?

The first line of input contains two integers $n$ and $m$ ($1\leq n\leq 10^5, 1\leq m\leq 10^5$) — the number of cone molds and the number of batter spreaders.

The second line of input contains $n$ distinct integers $p_1,\dots,p_n$ ($1\leq p_i\leq 10^6$), denoting a cone mold located at $(p_i, 0)$.

The next $m$ lines contain three integers $l_i, r_i, h_i$ ($1\leq l_i \leq r_i,\leq 10^6, 1\leq h_i\leq 10^9$, $l_i \leq r_i$), denoting a batter spreader covering the interval $[l_i,r_i]$ located at height $h_i$. It is guaranteed that no two spreaders intersect.

Output a single integer — the maximum number of cone molds you can fill by activating exactly one batter dispenser.

Input

The first line of input contains two integers $n$ and $m$ ($1\leq n\leq 10^5, 1\leq m\leq 10^5$) — the number of cone molds and the number of batter spreaders.

The second line of input contains $n$ distinct integers $p_1,\dots,p_n$ ($1\leq p_i\leq 10^6$), denoting a cone mold located at $(p_i, 0)$.

The next $m$ lines contain three integers $l_i, r_i, h_i$ ($1\leq l_i \leq r_i,\leq 10^6, 1\leq h_i\leq 10^9$, $l_i \leq r_i$), denoting a batter spreader covering the interval $[l_i,r_i]$ located at height $h_i$. It is guaranteed that no two spreaders intersect.

Output

Output a single integer — the maximum number of cone molds you can fill by activating exactly one batter dispenser.

5 2
1 2 3 4 5
1 2 1
3 5 2
2 2
1 1000000
1 500000 1
500000 1000000 2
3
2