Aloha is a poor guy who likes riding a bike. But he is too poor to afford a bicycle.
Recently, the Boom's bike-sharing service entered his school. It only costs

yuan for every single rent of a bicycle. From then on, Aloha could rent a bike and enjoy the speed and passion of riding.
The Boom's company has launched a promotion program named the

. In this program, users can buy discount cards with several free rents and a valid period. For example, after purchasing a discount card with

free rents and

days of valid time, one doesn't need to pay extra fees for the following

rents in the next

days. Note that, no matter when the card is bought on day

, it will always expire at the end of day

. Also, any new discount card overrides the previous one even if it is still valid, i.e., the remaining free rents of the previous discount card are voided immediately when the new discount card is purchased.
There are

different types of discount cards in the

. A card of

th type with

free rents and a valid period of

days costs

yuan. One can buy any type of discount card unlimited times.
Given the rental records, Aloha wants to know the minimum money he has to pay, provided that he takes the best strategy.