P12657 [AOJ] Shopping
普及
题目描述

Example

Input

10 3
3 7
8 9
2 5

Output

23

输入格式

见题面

输出格式

见题面

样例输入
10 3 3 7 8 9 2 5
样例输出
23