cho.sh
Notes
Loading...

Text Message Fees

Time limit

2s

Memory limit

128 MB

Problem

Minsik Telecom is a mobile carrier. Under its basic plan, each text message costs 10 won.

The company also sells text-message packs. When a customer buys a pack, they may send a fixed number of text messages without paying the basic per-message fee for those messages. Each kind of pack may be bought any number of times. If the customer sends more messages than the total number covered by purchased packs, every uncovered message is charged at the basic rate.

Youngsik wants to minimize his monthly bill. He sends T text messages in one month. There are two kinds of text-message packs. The first pack costs P1 won and covers K1 messages. The second pack costs P2 won and covers K2 messages. He may buy both kinds of packs, and the total number of messages covered by purchased packs may exceed T.

Input

The first line contains five integers T, K1, P1, K2, and P2.

Output

Output the minimum possible monthly fee.

Constraints

  • 0 <= T <= 10^12
  • 1 <= K1, K2 <= 10^12
  • 1 <= P1, P2 <= 10^13
  • P1 <= 20 * K1
  • P2 <= 20 * K2