#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y){
int tp=x%y;
while(tp){
x=y;y=tp;tp=x%y;
}
return y;
}
int lcm(int x,int y)
{
return x*y/gcd(x,y);
}
int main(){
int x,y;
cin>>x>>y;
int zdgys=gcd(x,y),zxgbs=lcm(x,y),ans=0;
for(int i=zdgys;i<=sqrt(x*y);i++){
if(gcd(i,x*y/i)==zdgys&&lcm(i,x*y/i)==zxgbs) ans++;
}
cout<<ans*2;
return 0;
}