Module: Sorting with comparator


Problem

9/11

Patties

Problem

Modify the program so that it solves the following problem.

Petya is very fond of pies with various fillings, and it is not so important with which one. Once, being in a hungry state, Petya went into the buffet and saw that there were pies with potatoes, cabbage and rice on sale. Petya wants to buy as many pies as possible, but the problem is that the number of pies on sale is limited in the same way as Petya's amount of money.
 
Help Petya determine the maximum possible number of pies he can buy.
 
Input
The first line contains the numbers P1, P2 and P3< /sub> – the cost of pies with potatoes, cabbage and rice, respectively. The second line defines the values ​​N1, N2 and N3 – the number of matching pies on sale. The third line contains the number R – the amount of money Petya has. All numbers in the input are positive integers not exceeding 1000.
 
Output
Print one integer - the answer to the problem.

 
Examples
# Input Output
1
5 3 8
2 6 4
23
7