PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000091. Chọn nhiều ước chung đôi một nguyên tố cùng nhau (Disjoint Set of Common Divisors)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Chọn nhiều ước chung đôi một nguyên tố cùng nhau (Disjoint Set of Common Divisors)

Disjoint Set of Common Divisors

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

Given two positive integers AA and BB, choose a set of their positive common divisors. Every two distinct chosen divisors must be coprime (their GCD is 11). Find the maximum possible number of chosen divisors. The number 11 is a valid common divisor.

Input

One line containing AA and BB.

Output

Print the maximum possible size of the set.

Subtasks

  • Subtask 1 (20 points): 1≤A,B≤1041\le A,B\le10^4
  • Subtask 2 (30 points): 1≤A,B≤1081\le A,B\le10^8
  • Subtask 3 (50 points): 1≤A,B≤10121\le A,B\le10^{12}

Examples

Input

12 18

Output

3

Explanation

The common divisors are 1,2,3,61,2,3,6. The set {1,2,3}\{1,2,3\} has three elements and is pairwise coprime. The divisor 66 cannot be added together with either 22 or 33, so the maximum is 33.