Problem F. Factorio

Author:A. Usmanov, L. Verkhovtsev. Translation: A. Logutova.   Time limit:1 sec
Input file:Standard input   Memory limit:256 Mb
Output file:Standard output  

Statement

Leonid is an astronaut. His spaceship crashed on far unknown planet, full of natural resources. Leonid couldn't repair his spaceship, therefore he stayed on the planet. Many years later he achieved fantastic progress in planet exploration — he built an ore mining and processing mill.

The mill works in several stages:

1. N drills mine the ore. The speed of one drill is UN kilograms per hour;

2. The ore gets to melting furnaces. The speed of one furnace is UK kilograms per hour;

3. After furnaces, plates get to M machine-tools. The speed of one machine-tool is UM kilograms per hour.

Leonid's mill pollutes the planet. This pollution disturbed inhabitants of the planet. Fictional arthropods have broken all furnaces.

Leonid is planning to build new furnaces and to renew manufacture. But at first he wants to calculate an optimal number of furnaces. We will call "surplus" the total quantity of the ore and plates, which is waiting for the processing. The number of furnaces is optimal if the surplus is minimal for the fixed period of time.

Help Leonid to calculate optimal number of furnaces. Obviously, Leonid wants to renew manufacture as fast as possible. Therefore among all possible answers, you should choose the minimal one.

Input format

The first line contains two integers N and M — the number of drills and machine-tools respectively.

The second line contains three integers UN, UK and UM — the speeds of one drill, one furnace and one machine-tool respectively.

Output format

Print an integer — optimal number of furnaces.

If there are several possible answers, choose the minimal one.

Constraints

1 ≤ N, M, UN, UK, UM ≤ 109

Sample tests explanation

Let's consider first test. Let's fix the period of time — T = 10 hours. Amount of produced resources is shown in the table.

Number of furnaces Mined ore, kg Melted ore, kg Surplus ore, kg Processed plates, kg Surplus plates, kg Surplus ore and plates, kg
1100 307030070 + 0
2 604060040 + 0
3 9010702010 + 20
4 100070300 + 30

Surpluses are equal for three and four furnaces, which means that three furnaces is enough.

Sample tests

No. Standard input Standard output
1
10 7
1 3 1
3
2
6 4
2 5 3
3
3
13 11
2 6 3
5

0.076s 0.015s 13