#Q2. 「一本通 1.1 例 2」种树

「一本通 1.1 例 2」种树

Description

A street is divided into nn segments, numbered consecutively from 11 to nn. Each segment can plant at most one tree. Residents have provided hh sets of suggestions, each consisting of three integers bb, ee, and tt, indicating that residents wish to plant at least tt trees between segments bb and ee (inclusive). The intervals suggested by these recommendations may overlap. The question is: what is the minimum number of trees that need to be planted to satisfy all residents' suggestions?

Input Format

The first line contains nn, the number of street segments.

The second line contains hh, the number of suggestions.

The following hh lines each describe a suggestion with three integers: bb, ee, tt, separated by spaces.

Output Format

Output a single integer representing the minimum number of trees required to meet all residents' suggestions.

Sample 1

9
4
1 4 2
4 6 2
8 9 2
3 5 2

5

Data Range and Hints

For 30%30\% of the data, 0<n10000<n\le 1000 and 0<h5000<h\le 500;

For 100%100\% of the data, 0<n3×1040<n\le 3\times 10^4, h5000h\le 5000, 0<be3×1040<b\le e\le 3\times 10^4, and teb+1t\le e-b+1.