Mirko's work shift lasts N minutes, and the minutes are numbered from 1 to N. He is given K jobs; each job is defined by a start time P and a duration T, meaning the job runs for T consecutive minutes, from minute P through minute P+T−1.
At every moment Mirko is either processing exactly one job or doing nothing and reading the newspaper. At the very start of his shift he is free (reading the newspaper).
The rules are:
By wisely choosing which job to take when several start at the same minute, Mirko can increase the time he spends reading. Compute the maximum number of minutes Mirko can spend reading the newspaper if he chooses optimally.
The first line contains two integers N and K (1 ≤ N ≤ 10000, 1 ≤ K ≤ 10000). N is the length of the shift in minutes and K is the number of jobs.
Each of the next K lines contains two integers P and T, meaning that a job starts at minute P and lasts T minutes (1 ≤ P ≤ N, 1 ≤ P+T−1 ≤ N).
Print a single integer: the maximum number of minutes Mirko can spend reading the newspaper.