All numbers are integers and non-negative. Given numbers S1, S3, S5, S10 and B > 0: there are S1 one-coin coins, S3 three-coin coins, S5 five-coin coins. and S10 ten-coin coins. How many coins are needed to pay off B soms? If this is not possible, output the number 0.
Input data format Integers S1, S3, S5, S10 < 2023 and 0 < B < 30000 separated by single spaces.
Output data format Non-negative integer.
Input data Output data
5 6 56 400 2 === 2
116 3 0 0 14 === 8
0 0 18 2000 15005 === 1501
2 0 600 1500 23 === 0