eolymp
bolt
Try our new interface for solving problems
Problems

Olympiad

Olympiad

$n$ teams arrived to the Informatics Olympiad. Each team consists of $a_i$ boys and $b_i$ girls. The participants can live in rooms with $m$ 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. \InputFile The first line contains the values of $n$ and $m$. In the next $n$ lines the pairs of numbers $a_i, b_i~(1 \le i \le n)$ are given. All numbers are positive integers not greater than $100$. \OutputFile Print the minimum required number of rooms.
Time limit 1 second
Memory limit 128 MiB
Input example #1
2 3
2 1
3 2 
Output example #1
3