Microwave

Given a start temperature below target, compute total heating time using per-degree rates for frozen and unfrozen states plus a fixed thawing time.

Easy2MathImplementationSimulationInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

To prepare a meal, JOI wants to heat a piece of meat from AA°C to BB°C in a microwave. The meat is frozen when its temperature is below 0°C and not frozen when it is above 0°C. When the temperature is exactly 0°C, the meat may be either frozen or not frozen.

JOI assumes that the meat heats up according to the rules below and uses them to estimate how long the heating takes.

  • While the meat is frozen and its temperature is below 0°C, the temperature rises by 1°C every CC seconds.
  • While the meat is frozen and its temperature is exactly 0°C, thawing it into the not frozen state takes DD seconds.
  • While the meat is not frozen, the temperature rises by 1°C every EE seconds.

Using these rules, find how many seconds it takes to heat the meat to BB°C.

Input

The input has five lines, each containing one integer.

  • The first line contains the initial temperature AA of the meat. AA is between 100-100 and 100100 inclusive and is not 0.
  • The second line contains the target temperature BB. BB is between 11 and 100100 inclusive and is greater than AA.
  • The third line contains CC, the time needed to raise the temperature of frozen meat by 1°C.
  • The fourth line contains DD, the time needed to thaw frozen meat.
  • The fifth line contains EE, the time needed to raise the temperature of meat that is not frozen by 1°C.

CC, DD, and EE are each between 11 and 100100 inclusive.

Output

Print on one line the time in seconds needed to heat the meat to BB°C.

Hint

In sample 1, the meat starts frozen at 10-10°C. The time is made up as follows.

  • Heating from 10-10°C to 0°C takes 5×10=505 \times 10 = 50 seconds.
  • Thawing the meat at 0°C takes 10 seconds.
  • Heating from 0°C to 20°C takes 3×20=603 \times 20 = 60 seconds.

The total is 120 seconds.

In sample 2, the meat is not frozen at the start, so heating it from 35°C to 92°C takes 627 seconds.