353. Billing

Time limit per test: 0.25 second(s)
Memory limit: 65536 kilobytes
input: standard
output: standard

A girl named Kate has a contract with the Berland only cell phone operator BTS. Her tariff plan is called "Very Profitable" and all Kate can do is to make phone calls. All incoming calls are free. The outgoing calls are billed in the following way: at the very beginning of the call Kate's account is charged p1 cents for the first k1 seconds of the call. Each of the next k2 seconds costs p2 cents. And all remaining time costs p3 cents per second. The account is always billed instantly at the end of each second. If the account balance becomes non-positive, the call is automatically dropped.

Kate has put N cents to her account and she is going to talk with her very good friend. Kate would like to know what is the maximum number of seconds she can talk during a single call.

If N < p1, Kate does not have enough money to establish the call.

The input contains 6 integer numbers N, k1, k2, p1, p2, p3, (; ; ).

Write to the output just one integer number — the maximum number of seconds Kate can talk.

sample input
sample output
20 3 3 3 4 2

sample input
sample output
3 15 3 5 2 3

sample input
sample output
1 1 1 1 3 1

sample input
sample output
2 1 1 1 3 1

Online Contester Team © 2002 - 2010. All rights reserved.