#DP1051. FTL
FTL
Description
Monocarp is playing a video game. In the game, he controls a spaceship and has to destroy an enemy spaceship.
Monocarp has two lasers installed on his spaceship. Both lasers and have two values:
• — the power of the laser; • — the reload time of the laser.
When a laser is fully charged, Monocarp can either shoot it or wait for the other laser to charge and shoot both of them at the same time.
An enemy spaceship has durability and shield capacity. When Monocarp shoots an enemy spaceship, it receives damage (i. e. gets subtracted from its durability), where is the total power of the lasers that Monocarp shoots (i. e. if he only shoots laser and if he shoots both lasers at the same time). An enemy spaceship is considered destroyed when its durability becomes or lower.
Initially, both lasers are zero charged.
What's the lowest amount of time it can take Monocarp to destroy an enemy spaceship?
Format
Input
The first line contains two integers and (; ) — the power and the reload time of the first laser.
The second line contains two integers and (; ) — the power and the reload time of the second laser.
The third line contains two integers and (; ) — the durability and the shield capacity of an enemy spaceship. Note that the last constraint implies that Monocarp will always be able to destroy an enemy spaceship.
Output
Print a single integer — the lowest amount of time it can take Monocarp to destroy an enemy spaceship.
Samples
5 10
4 9
16 1
20
Limitation
time limit per test
4 seconds
memory limit per test
512 megabytes