#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x,y;
ll gcd(ll a,ll b) {
return b==0?a:gcd(b,a%b);
}
int c=0;
int main(){
ios::sync_with_stdio(0);
cin>>x>>y;
for(ll i=1;;i++){
if((x*y)%i==0){
ll j = x * y / i;
if(i<=j){
ll g = gcd(j,i);
ll l = i*j/g;
if(g==x && l== y){
if(i==j){
c++;
}else{
c+=2;
}
}
}else{
break;
}
}
}
cout<<c;
return 0;
}