#Z15106. 校门外的树

校门外的树

Description

There is a row of trees along a road of length L outside a school gate, with an interval of 1 meter between every two adjacent trees. We can regard 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, i.e., 0, 1, 2, ..., L, has a tree planted on it.

Some sections of the road are to be used for subway construction. These sections are represented by their starting and ending points on the number line. It is known that the coordinates of the starting and ending 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), where L represents the length of the road, and M represents the number of sections. L and M are separated by a space. The next M lines each contain two distinct integers, separated by a space, representing the starting and ending coordinates of a section.

For 20% of the data, the sections do not overlap; for the remaining data, there may be overlapping sections.

Output Format

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

500 3
150 300
100 200
470 471


298