e-olymp
favorite We need a little bit of your help to keep things running, click on this banner to learn more
Competitions

2013 Petrozavodsk, February 2

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 (-1018a, b1018, 1n100). The second line contains integers c, d and m (-1018c, d1018, 1m100). It is guaranteed that a2 + b2 > 0 и c2 + d2 > 0.

Output

Print one integer: the answer to the problem.

Time limit 1 second
Memory limit 128 MiB
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
Author M.Rubinchik, O.Soboleva
Source 2013 Petrozavodsk, Winter, Ural FU contest, Kontur Cup, Problem A