#T613. 校门外的树

校门外的树

Description

Outside the gate of a certain school, there is a row of trees along a road of length L, with each adjacent pair of trees spaced 1 meter apart. We can visualize the road as a number line, where one end of the road is at position 0 on the number line and the other end is at position L. Every integer point on the number line—0, 1, 2, ..., L—has a tree planted on it.

Some sections of the road are designated for subway construction. These sections are represented by their start and end points on the number line. It is known that the coordinates of the start and end points of any section are integers, and the sections may overlap. Now, all the trees within these sections (including the trees at the endpoints) must be removed. Your task is to calculate how many trees remain on the road after the removal.

Input Format

The first line contains two integers, L (1 ≤ L ≤ 10000) and M (1 ≤ M ≤ 100), separated by a space. Here, L represents the length of the road, and M represents the number of sections. The next M lines each contain two distinct integers, separated by a space, representing the start and end coordinates of a section.

For 20% of the test cases, the sections do not overlap. For the remaining cases, overlapping sections may occur.

Output Format

The output consists of a single line containing one integer, representing the number of remaining trees on the road.

```input1 500 3 150 300 100 200 470 471
```output1
298

## Source

CodesOnline