100 atcoder#ABC142D. [ABC142D] Disjoint Set of Common Divisors

[ABC142D] Disjoint Set of Common Divisors

Score : 400400 points

Problem Statement

Given are positive integers AA and BB.

Let us choose some number of positive common divisors of AA and BB.

Here, any two of the chosen divisors must be coprime.

At most, how many divisors can we choose?

Definition of common divisor

An integer dd is said to be a common divisor of integers xx and yy when dd divides both xx and yy.

Definition of being coprime

Integers xx and yy are said to be coprime when xx and yy have no positive common divisors other than 11.

Definition of dividing

An integer xx is said to divide another integer yy when there exists an integer α\alpha such that y=αxy = \alpha x.

Constraints

  • All values in input are integers.
  • 1A,B10121 \leq A, B \leq 10^{12}

Input

Input is given from Standard Input in the following format:

AA BB

Output

Print the maximum number of divisors that can be chosen to satisfy the condition.

12 18
3

1212 and 1818 have the following positive common divisors: 11, 22, 33, and 66.

11 and 22 are coprime, 22 and 33 are coprime, and 33 and 11 are coprime, so we can choose 11, 22, and 33, which achieve the maximum result.

420 660
4
1 2019
1

11 and 20192019 have no positive common divisors other than 11.