Twin Eagles

Find the fewest days for two eagles dealing LH damage per attack to kill a lion and a bear that heal each night, or output -1.

Medium6Binary searchMathGreedyNo attempts yetTime limit1sMemory limit32 MB

Problem

Two twin eagles want to bring down the lion and the bear that live nearby. They are too weak for a head-on fight, so they attack only by surprise.

One eagle attacks for LHLH damage. The lion has SS health and the bear has DD health. When one eagle attacks an animal, that animal loses LHLH health. When both eagles attack the same animal, it loses 2×LH2 \times LH health.

The eagles attack once during each day, starting on day 1. Both of them may hit the same animal, or each of them may hit a different animal. They are weak, so after that one attack they cannot attack again on the same day.

Every night, the lion and the bear recover LL and BB health, but only if they are still standing. Health can grow without any bound. An animal falls as soon as its health drops to 0 or below, and a fallen animal never recovers and never needs to be attacked again.

Find the smallest number of days the eagles need to bring down both animals.

Input

The first line contains the eagle attack power LHLH, the lion health SS, the bear health DD, the lion recovery LL, and the bear recovery BB, separated by spaces.

  • 1LH,S,D1091 \le LH, S, D \le 10^9
  • 0L,B1090 \le L, B \le 10^9

Output

Print the smallest number of days needed to bring down both the lion and the bear. The answer can exceed the range of a 32-bit integer.

If the eagles can never bring down both animals, no matter how many days pass, print -1.