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 of input contains integers a, b, and 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 and c2 + d2 > 0.
Output
Output one integer: the answer to the problem.
Samples
input | output |
---|
0 1 2
1 0 2
| 0
|
1 0 2
1 0 4
| 2
|
Problem Author: Mikhail Rubinchik (prepared by Olga Soboleva)
Problem Source: Ural FU contest. Kontur Cup. Petrozavodsk training camp. Winter 2013