Problem:
Score : 400 points

Problem Statement

Given are positive integers A and B.

Let us choose some number of positive common divisors of A and B.

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

At most, how many divisors can we choose?

Definition of common divisor

An integer d is said to be a common divisor of integers x and y when d divides both x and y.

Definition of being coprime

Integers x and y are said to be coprime when x and y have no positive common divisors other than 1.

Definition of dividing

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

Constraints

All values in input are integers.

1 \leq A, B \leq 10^{12}

Input

Input is given from Standard Input in the following format:

A B

Output

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

Sample Input 1

12 18

Sample Output 1

3

12 and 18 have the following positive common divisors: 1, 2, 3, and 6.

1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.

Sample Input 2

420 660

Sample Output 2

4

Sample Input 3

1 2019

Sample Output 3

1

1 and 2019 have no positive common divisors other than 1.

Solution in C (GCC 5.4.1) (judge verdict: Accepted)

#include <stdio.h>

//素数列挙
//pには充分な要素数の配列のアドレス、返り値は個数
#include <stdbool.h>
#define n0 500000 //上限/2
#define n1 500    //sqrt(上限)/2

int prime(long *p){
  bool fp[n0]={};
  int i,j,np=1,s;
  for(i=0;i<n1;i++){
    if(fp[i]) continue;
    s=(i<<1)+3;
    for(j=(i+1)*3;j<n0;j+=s){
      fp[j]=1;
    }
  }
  p[0]=2;
  for(i=0;i<n0;i+=1){
    if(fp[i]^1){
      p[np]=(long)(i<<1)+3;
      np++;
    }
  }
  return(np);
}

int main(){
  bool b[2][80000]={};
  int i,j,np,m=1;
  long a,p[80000];
  np=prime(&p);
  for(i=0;i<2;i++){
    scanf("%ld",&a);
    for(j=0;j<np;j++){
      while(a%p[j]==0){
        a/=p[j];
        b[i][j]=1;
      }
    }
    if(a!=1){
      p[np]=a;
      b[i][np]=1;
      np++;
    }
  }
  for(i=0;i<np;i++){
    m+=b[0][i]&b[1][i];
  }
  printf("%d",m);
  return(0);
}