eolymp
bolt
Try our new interface for solving problems
Problems

Number

Number

Given the numbers a, b, c and d find the smallest positive integer n, greater than a * c, which cannot be represented as the product of two natural numbers u and v such that aub и cvd.

Input

Positive integers a, b, c, d (1ab106, 1cd106).

Output

Print the desired number n.

Time limit 1 second
Memory limit 128 MiB
Input example #1
1 2 1 2
Output example #1
3
Input example #2
1 2 3 5
Output example #2
7
Source 2006, XIV St. Petersburg School Programming Team Championship, November 6, Problem H