eolymp
bolt
Try our new interface for solving problems
Problems

Dragon

Dragon

Time limit 1 second
Memory limit 64 MiB
prb16

Every centipede has S legs and 1 head. Find the quantity of legs N of a K-head dragon, if there is total of A heads and B legs.

Input data

4 numbers: S, K, A, B. Every numbers is less or equals to 1000. It is guaranteed that there is at least one dragon and one centipede.

Output data

The number of legs of a dragon. If input data is contradiction, then output -1, if there is more than one answer, output any one of them.

Examples

Input example #1
4 7 35 36
Output example #1
2