#include<bits/stdc++.h>
using namespace std;
long x,y,p,q,i,s;
int hz(long p,long q)
{
long j;
for(j=2;j<=p;j++)
if(p%j==0&&q%j==0)
return 0;
return 1;
}
int main()
{
while(cin>>x>>y)
{
if(y%x!=0)
cout<<0<<endl;
else if(y==x) cout<<1<<endl;
else
{
s=0;
i=y/x;
for(p=1;p<=i;p++)
for(q=1;q<=i;q++)
if((p*q==y/x)&&hz(p,q))
s++;
cout<<s<<endl;
}
}
return 0;
}
using namespace std;
long x,y,p,q,i,s;
int hz(long p,long q)
{
long j;
for(j=2;j<=p;j++)
if(p%j==0&&q%j==0)
return 0;
return 1;
}
int main()
{
while(cin>>x>>y)
{
if(y%x!=0)
cout<<0<<endl;
else if(y==x) cout<<1<<endl;
else
{
s=0;
i=y/x;
for(p=1;p<=i;p++)
for(q=1;q<=i;q++)
if((p*q==y/x)&&hz(p,q))
s++;
cout<<s<<endl;
}
}
return 0;
}