Food Program#181

Food Program

1 second
64 megabytes
Hard

Returning from another campaign, Orgrim Doomhammer found that his settlement had been completely destroyed by human forces. Now, he must rebuild the city from its ruins.

First of all, the Warchief must solve the food problem by constructing enough farms (pig farm) so that his warriors and workers do not die of hunger. Naturally, Orgrim enlists all his peons (laborers) for this work.

Constructing a single farm requires G_f units of gold and provides food for P_f orcs. However, each farm must be built in the immediate vicinity of a great hall (great hall). Therefore, a certain number of great halls must be constructed beforehand. No more than farms can be built near one great hall. Additionally, building each great hall requires G_h units of gold and it can provide food for P_h orcs.

Help Orgrim develop a food program to determine how many great halls and farms should be built to provide food for orcs, while spending the minimum possible amount of gold on construction.

Input

The input consists of a single line containing six integers: , , G_h, P_h, G_f, P_f (0 \leq N \leq 10^6, 1 \leq F \leq 100, 1 \leq G_h, G_f \leq 2000, 0 \leq P_h, P_f \leq 1000, P_f \neq 0).

Output

Output a single integer in one line — the minimum amount of gold required.

Examples

Example 1

Loading
Loading