Problems
Complex Root
Complex Root
Your task is to find how many complex numbers x satisfy the following two conditions: xn
= a + bi and xm
= c + di.
Input
The first line contains integers a, b, n (-1018
≤ a, b ≤ 1018
, 1 ≤ n ≤ 100). The second line contains integers c, d and m (-1018
≤ c, d ≤ 1018
, 1 ≤ m ≤ 100). It is guaranteed that a2
+ b2
> 0 и c2
+ d2
> 0.
Output
Print one integer: the answer to the problem.
Input example #1
0 1 2 1 0 2
Output example #1
0
Input example #2
1 0 2 1 0 4
Output example #2
2