Olympiad#4192

Olympiad

1 second
128 megabytes
Medium (≈1350)

teams arrived to the Informatics Olympiad. Each team consists of a_i boys and b_i girls. The participants can live in rooms with places in each. Find the minimum number of rooms needed to accommodate all the Olympiad participants, if the boys can't be settled with the girls.

Input

The first line contains the values of and . In the next lines the pairs of numbers a_i, b_i~(1 \le i \le n) are given. All numbers are non-negative integers not greater than .

Output

Print the minimum required number of rooms.

Examples

Example 1

Loading
Loading