Олимпиадный тренинг

Задача 26980. Paper for the Olympics


Задача

Темы: Вывод формулы
Lyolik decided to host the Olympiad at his school. To do this, he needs to buy a lot of paper packages. Lelik was very lucky because a large stationery store announced two promotions: "Buy A of the same items and get another item for free" and "Buy B items for the price of B-1 item". 
Lyolik found out that one pack of paper in this store costs n rubles. Now he wants to determine how many packs of paper he can buy for p rubles. Help him. 
 
Input Format
The input is four natural numbers separated by spaces: A, B, p and n (1 ≤   A ≤   100, 2 ≤   B ≤   100, 1 ≤   p, n   10000). 
 
Output format
Print a single integer — the maximum number of packages of paper that Lyolik can buy. 

Example
Enter Output
4 4 13 2 8
3 4 8 3 2
3 4 7 1 9
 
Notes
In the first example, using the second share twice, you can buy 8 packs of paper, paying for 6. 
In the second example, promotions cannot be used. 
In the third example, you can use each of the two shares once and buy another package of paper with the remaining ruble.