#P434. 练75.2采购奖品

练75.2采购奖品

Description

The annual New Year party is coming soon. Xiao Ming, as the class monitor, is responsible for organizing and planning the event. He decides to purchase some prizes to reward students who actively participate in each activity. To encourage more participation, the number of prizes purchased should be as large as possible. The class fund can spend up to mm yuan. Given the prices and stock quantities of nn types of items available in the store, how can Xiao Ming buy the maximum number of items?

Input Format

The input consists of n+1n+1 lines:
The first line contains two positive integers mm (1<m100001< m \leq 10000) and nn (1<n1001 < n \leq 100), representing the available budget and the number of types of items available for purchase.
The next nn lines each contain two numbers (separated by a space), representing the unit price aa and stock quantity bb of each item. Both aa and bb do not exceed 10001000.

Output Format

An integer representing the maximum number of items that can be purchased.

Sample

500 6
100 3
20 15
50 10
35 5
5 6
60 2
25