Problem A
Making A Meowth
![/problems/makingameowth/file/statement/en/img-0001.jpg](/problems/makingameowth/file/statement/en/img-0001.jpg)
After suffering an embarrassing defeat at the hands of Team Rocket, you come to the obvious conclusion that the only way to beat them is by teaching your own Meowth how to read.
To prevent burn out, you’ve created the following study plan: your Meowth will read every $N$th page, and you will read everything else aloud to them. But, because you have other things to do (Pokemon to catch, battles to win, what-have-you), you are only willing to read $P$ pages in one sitting. You always read first. If it is Meowth’s turn to read once you finish your last page, let them read; you want them to practice as much as possible, after all! Otherwise, the session is over as soon as you complete your last page (even if Meowth doesn’t end up reading a single page). If it takes you $X$ minutes to read a page and your Meowth $Y$ minutes to read a page, how much time, in minutes, will you spend reading together?
Input
The only line of input contains 4 space-separated positive integers, $N$, $P$, $X$, $Y$ ($2 \leq N, P \leq 10^{7}, 1 \leq X, Y \leq 60$).
Output
Output one line containing a single integer: the amount of time in minutes you and your Meowth will spend reading together.
Sample Input 1 | Sample Output 1 |
---|---|
4 10 2 3 |
29 |
Sample Input 2 | Sample Output 2 |
---|---|
3 14 2 5 |
63 |
Sample Input 3 | Sample Output 3 |
---|---|
10 4 2 3 |
8 |