G. Social Network
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

There are $$$n$$$ people numbered from $$$1$$$ to $$$n$$$ in a social network. We have $$$m$$$ pieces of information that tell us their connections, in which the $$$i$$$-th one gives us that $$$x_i$$$ are friends with anyone with number $$$y$$$, where $$$L_i\le y\le R_i$$$. Basically, person $$$x_i$$$ is with the range of people from $$$L_i$$$ to $$$R_i$$$.

Now, Harry wants to notify them of an important message. The only way for him to do that is by sending messages to some individuals in the network. If anyone receives a message, he or she will share the message with all his or her friends. Given that friendship is mutual and all pairs of friends are included in our information, what is the minimum number of messages Harry needs to send so that everyone in the network receives the message?

Input

The first line contains two integer $$$n,m$$$ $$$(1\le n\le 10^{12},1\le m\le 2\times 10^5)$$$.

The next $$$m$$$ line each contains three integer $$$x_i,L_i,R_i$$$ $$$(1\le x_i\le n,1\le L_i\le R_i\le n)$$$.

Output

Output a single integer, the minimum number of messages Harry needs to send so that everyone in the network receives the message.

Examples
Input
5 3
1 2 2
2 3 3
3 4 4
Output
2
Input
7 2
1 2 4
6 2 3
Output
3
Input
10 4
2 3 6
1 2 3
8 7 9
3 1 5
Output
3