Dominoes#4195

Dominoes

1 second
64 megabytes
Medium
Dominoes

A domino is a rectangular tile divided into two squares, each displaying between zero and six dots. A row of dominoes is laid out on the table. The sum of the values in the top row is 6+1+1+1 = 9, and in the bottom row, it is 1+5+3+2 = 11. The difference between the top and bottom rows is , calculated as the absolute value of the difference between the two sums. Each domino can be rotated by degrees, which swaps the top and bottom squares.

What is the minimum number of rotations needed to minimize the difference between the sums of the rows?

Input

The first line contains a natural number (1 \le N \le 1000). The following lines each contain two non-negative integers ranging from to – these represent the values of the top and bottom squares of the -th domino (i=1..N).

Output

Output a single number, which is the answer to the problem.

Examples

Example 1

Loading
Loading