This problem is a programming version of Problem 225 from projecteuler.net
The sequence , , , , , , , , , , , , , ... is defined by and .
It can be shown that does not divide any terms of this sequence. In fact, is the first odd number with this property.
Given , and , find the th odd number that does not divide any terms of the above sequence.
First and only line of each test file contains four integers separated by single spaces: , , and .
Print exactly one number that is the answer to the problem.
Sample Input 0
1 1 1 1
Sample Output 0
Sample Input 1
1 29 19 131
Sample Output 1
Happy New Year!