#include <stdio.h>
#include <math.h>
int c(int a,int b);
int x,y,v;
int c(int a,int b)
{
int o;
while (b!=0)
{
o=a%b;
a=b;
b=o;
}
return(a);
}
main()
{
int i,n,s;
scanf("%d%d",&x,&y);
n=0;
v=x*y;
s=sqrt(v);
for (i=x;i<=s;i=i+x)
if ((c(v/i,i)==x)&&(v%i==0)) n++;
n=n*2;
printf("%d",n);
getchar();
getchar();
return(0);
}
#include <math.h>
int c(int a,int b);
int x,y,v;
int c(int a,int b)
{
int o;
while (b!=0)
{
o=a%b;
a=b;
b=o;
}
return(a);
}
main()
{
int i,n,s;
scanf("%d%d",&x,&y);
n=0;
v=x*y;
s=sqrt(v);
for (i=x;i<=s;i=i+x)
if ((c(v/i,i)==x)&&(v%i==0)) n++;
n=n*2;
printf("%d",n);
getchar();
getchar();
return(0);
}