Complex Root#5609

Complex Root

1 second
128 megabytes
Easy

Your task is to find how many complex numbers satisfy the following two conditions: x^n = a + bi and x^m = c + di.

Input

The first line contains integers , , (-10^{18} \le a, b \le 10^{18}, 1 \le n \le 100). The second line contains integers , and (-10^{18} \le c, d \le 10^{18}, 1 \le m \le 100). It is guaranteed that a^2 + b^2 > 0 and c^2 + d^2 > 0.

Output

Print one integer: the answer to the problem.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading