#abc142d. [abc142_d]Disjoint Set of Common Divisors
[abc142_d]Disjoint Set of Common Divisors
Problem Statement
Given are positive integers and .
Let us choose some number of positive common divisors of and .
Here, any two of the chosen divisors must be coprime.
At most, how many divisors can we choose?
Definition of common divisor
An integer is said to be a common divisor of integers and when divides both and .
Definition of being coprime
Integers and are said to be coprime when and have no positive common divisors other than .
Definition of dividing
An integer is said to divide another integer when there exists an integer such that .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum number of divisors that can be chosen to satisfy the condition.
Sample Input 1
12 18
Sample Output 1
3
and have the following positive common divisors: , , , and .
and are coprime, and are coprime, and and are coprime, so we can choose , , and , which achieve the maximum result.
Sample Input 2
420 660
Sample Output 2
4
Sample Input 3
1 2019
Sample Output 3
1
and have no positive common divisors other than .