Enemies
Limits: 1 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Right now, every expert is making their predictions about when the war will end. So Zenyk decided that he is no worse than them.
Zenyk is preparing for all possible developments, so he believes that the war will end only when the soldiers of the armies of both enemy countries — "r" and "b" — are gone. From his sources, he learned that the army of the first enemy country consists of \(A\) soldiers, and the second — of \(B\). Also, for simplicity, he assumes that every day the first enemy country will lose exactly \(C\) soldiers, and the second — exactly \(D\).
Help Zenyk calculate in how many days the war will end (according to his predictions).
Input
The single line contains four space-separated integers — \(A\), \(B\), \(C\), \(D\).
Output
Output a single integer — how many more days the war will last (according to Zenyk’s prediction).
Constraints
\(1 \le A, B, C, D \le 10^9\),
\(A\) is evenly divisible by \(C\), and \(B\) — by \(D\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 7 4 1 2 | 7 |
| Input (stdin) | Output (stdout) |
|---|---|
| 15 3 5 1 | 3 |
Notes
In the first test, the enemy armies consist of 7 and 4 soldiers, and lose 1 and 2 soldiers per day, respectively. Therefore, Zenyk believes that the army of the first enemy country will be depleted in 7 days, the second — in 2 days, and therefore the war will last for another 7 days.
In the second test, the armies of both enemy countries will be depleted in 3 days.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|