Perica was always very good at math. His only weak points were addition and division. To help him with that, his teacher presented him with the following problem.
She gave him a $2 \times 2$ table containing positive integers $A$, $B$, $C$ and $D$, arranged like this:
$$\begin{pmatrix} A & B \ C & D \end{pmatrix}$$
The value of the table is defined as
$$\frac{A + B}{C + D},$$
the sum of the numbers in the top row divided by the sum of the numbers in the bottom row.
Perica's task is to find the minimum number of $90^\circ$ clockwise rotations required to maximize the value of a given table. A single clockwise rotation transforms the table $\begin{pmatrix} A & B \ C & D \end{pmatrix}$ into $\begin{pmatrix} C & A \ D & B \end{pmatrix}$.
Input
The first line of input contains two space separated integers, $A$ and $B$.
The second line of input contains two space separated integers, $C$ and $D$.
All integers are positive and not greater than $100$.
Output
The first and only line of output must contain a single integer, minimum number of clockwise rotations required to maximize the table’s value.
Example 1
1 2 3 4
2
Example 2
5 9 7 2
0
Example 3
41 99 100 13
1
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.