ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

Ural FU contest. Kontur Cup. Petrozavodsk training camp. Winter 2013

About     Problems     Submit solution     Judge status     Standings
Contest is over

A. Complex Root

Time limit: 1.0 second
Memory limit: 64 MB
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 (−1018a, b ≤ 1018; 1 ≤ n ≤ 100). The second line contains integers c, d and m (−1018c, 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

inputoutput
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
To submit the solution for this problem go to the Problem set: 1951. Complex Root