Competitions

# 2013 Petrozavodsk, February 2

# Complex Root

Your task is to find how many complex numbers **x** satisfy the following two conditions: `x`

= ^{n}**a** + **bi** and `x`

= ^{m}**c** + **di**.

#### Input

The first line contains integers **a**, **b**, **n** (`-10`

≤ ^{18}**a**, **b** ≤ `10`

, ^{18}**1** ≤ **n** ≤ **100**). The second line contains integers **c**, **d** and **m** (-`10`

≤ ^{18}**c**, **d** ≤ `10`

, ^{18}**1** ≤ **m** ≤ **100**). It is guaranteed that `a`

+ ^{2}`b`

> ^{2}**0** и `c`

+ ^{2}`d`

> 0.^{2}

#### 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