#include <bits/stdc++.h>
using namespace std;
long long a, b, c, gcd, ans;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> a >> b;
while (b){
	c=b;
	b=a%b;
	a=c;
}
gcd=a; ans++; 
for (int i=2;i<=sqrt(gcd); i++){
	if (gcd%i==0){
		ans++;
		while (gcd%i==0){
			gcd/=i;
		}
	}
}
if (gcd>1) ans++;
cout << ans;
return 0;
}