#include <bits/stdc++.h>
using namespace std;
int x1,x2,x3,t=2,ave=0;
int main()
{
cin>>x1>>x2;
if(x2%x1==0)
x3=x2/x1;
else
{
cout<<0;
return 0;
}
for(int t=2;t<=x3;++t)
{
if(x3%t==0)
{
while(x3%t==0)
x3/=t;
++ave;
}
}
cout<<2+(ave-1)*ave;
return 0;
}