#include<bits/stdc++.h>
using namespace std;
int x,y;
int Count=0;
int gcd(int a,int b){
if(b!=0)return gcd(b,a%b);
return a;
}
int main(){
scanf("%d%d",&x,&y);
if(x>y){
int t=x;x=y;y=t;
}
if(y%x!=0)printf("0");
else{
int n=y/x;
int t=sqrt(n);
Count+=2;
for(int i=x;i<=t;i++){
if(n%i==0&&gcd(i,n/i)==1)Count+=2;
}
printf("%d",Count);
}
return 0;
}