#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int gcd(int a,int b){
return b?gcd(b,a%b):a;
}
int main(){
int x,y;
scanf("%d%d",&x,&y);
int ans=0;
for(int p=2;p<=sqrt(x*y);p++){
if(!(x*y%p)){//条件1
if(gcd(p,(x*y)/p)==x){
ans++;
}
}
}
printf("%d\n",ans*2);
return 0;
}