Page Count#1805

Page Count

1 second
64 megabytes
Easy

When you execute a word processor's print command, you are normally prompted to specify the pages you want printed. For example, you may enter:

10-15,25-28,8-4,13-20,9,8-8

The expression you enter is a list of print ranges separated by commas.

Each print range is either a single positive integer, or two positive integers separated by a hyphen. In the latter case, the first integer is called "low," and the second is called "high." A print range for which low high is ignored. If a print range specifies page numbers that exceed the number of pages, only the pages present in the document are considered. Pages are numbered starting from .

Some print ranges may overlap. Pages included in two or more print ranges are printed only once. (In the given example, pages 13, 14, and 15 are included in two print ranges.)

Input

The input will contain data for several problem instances. Each instance consists of two input lines. The first line contains a single positive integer: the number of pages in the document. The second line contains the list of print ranges as described above. End of input is indicated by for the number of pages. The number of pages in any document does not exceed . The list of print ranges does not exceed characters.

Output

For each problem instance, output a single number at the beginning of a new line. It is the number of pages printed by the print command.

Examples

Example 1

Loading
Loading