Problem list
Log in
#coci00163 · COCI 2010/2011 Contest 3

Tablica

Bronze III 1.0 s 32 MB

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

Input
1 2
3 4
Output
2

Example 2

Input
5 9
7 2
Output
0

Example 3

Input
41 99
100 13
Output
1
Source
COCI 2010/2011 Contest 3
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code